camerauis/cameraapp/generic/src/CamAppui.cpp
changeset 19 d9aefe59d544
parent 3 8b2d6d0384b0
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  App UI class for cameraapp
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // This needs to be included first, because other include files
       
    20 // may be variated using these flags.
       
    21 #include <avkon.hrh>
       
    22 #include <barsread.h>  // TResourceReader
       
    23 #include <StringLoader.h>
       
    24 #include <sysutil.h>
       
    25 #include <eikenv.h>
       
    26 #include <hlplch.h>
       
    27 #include <apgwgnam.h>
       
    28 #include <apgcli.h>
       
    29 #include <DocumentHandler.h>
       
    30 #include <apmstd.h>
       
    31 #include <textresolver.h>
       
    32 #include <aknnotewrappers.h>
       
    33 #include <akntitle.h>  // CAknTitlePane
       
    34 #include <aknclearer.h>
       
    35 #include <aknnavide.h>
       
    36 #include <AknWaitDialog.h>
       
    37 #include <aknstaticnotedialog.h>
       
    38 #include <AknCapServerDefs.h>
       
    39 #include <akntoolbar.h>
       
    40 #include <aknstyluspopupmenu.h>
       
    41 #include <aknlayoutscalable_apps.cdl.h>
       
    42 #include <akntoolbarextension.h>
       
    43 #include <eiksoftkeypostingtransparency.h>
       
    44 #include <centralrepository.h>
       
    45 #include <AknSgcc.h>
       
    46 #include <cameraapp.rsg>
       
    47 #include <vgacamsettings.rsg>
       
    48 #include <activepalette2ui.h>
       
    49 #include <AknGlobalNote.h>
       
    50 #include <hal.h>
       
    51 #include <hal_data.h>
       
    52 #include <oommonitorsession.h>
       
    53 #include <driveinfo.h>
       
    54 #include <pathinfo.h>
       
    55 
       
    56 #ifndef __WINSCW__
       
    57 //#include <SFIUtilsAppInterface.h>
       
    58 #endif
       
    59 
       
    60 #include <musresourceproperties.h>
       
    61 #include <cameraplatpskeys.h>
       
    62 
       
    63 #include <AknCommonDialogsDynMem.h>
       
    64 #include <CAknMemorySelectionDialogMultiDrive.h>
       
    65 
       
    66 #include "CameraappPrivateCRKeys.h"
       
    67 #include "CamAppUi.h"
       
    68 #include "CamUtility.h"
       
    69 #include "CamAppController.h"
       
    70 #include "CamControllerObservers.h"
       
    71 #include "CamTimer.h"
       
    72 #include "CamLogger.h"
       
    73 #include "CamStillPreCaptureView.h"
       
    74 #include "CamStillPostCaptureView.h"
       
    75 #include "CamVideoPreCaptureView.h"
       
    76 #include "CamVideoPostCaptureView.h"
       
    77 #include "CamBurstThumbnailView.h"
       
    78 #include "CamSelfTimer.h"
       
    79 #include "CamPanic.h"
       
    80 #include "CamBurstModeObserver.h"
       
    81 #include "CamStillUserSceneSetupView.h"
       
    82 #include "CamNaviCounterControl.h"
       
    83 #include "CamNaviCounterModel.h"
       
    84 #include "CamNaviProgressBarControl.h"
       
    85 #include "Cam.hrh"
       
    86 #include "CamSettings.hrh"
       
    87 #include "CamProductSpecificSettings.hrh"
       
    88 #include "CamAppUiBase.h"
       
    89 #include "CamWaitDialog.h"
       
    90 #include "CamSidePane.h"
       
    91 #include "CamZoomPane.h"
       
    92 #include "CamAppUid.h"
       
    93 #include <csxhelp/lcam.hlp.hrh>
       
    94 #include "CameraVariant.hrh"
       
    95 #include "OstTraceDefinitions.h"
       
    96 #ifdef OST_TRACE_COMPILER_IN_USE
       
    97 #include "CamAppUiTraces.h"
       
    98 #endif
       
    99 #include "camactivepalettehandler.h"
       
   100 #include "CamContainerBase.h"
       
   101 #include "camuidconstants.h"
       
   102 #include "CamGSInterface.h"
       
   103 #include "CamFileCheckAo.h"
       
   104 #include "CamLocalViewIds.h"
       
   105 #include "CameraUiConfigManager.h"
       
   106 
       
   107 #include "MCamAddToAlbumObserver.h"
       
   108 #include "CamCollectionManagerAo.h"
       
   109 #include "glxgallery.hrh"
       
   110 #include "glxcollectionplugincamera.hrh"
       
   111 #include "s32mem.h"
       
   112 
       
   113 
       
   114 #include "camflashstatus.h"
       
   115 #include "CamMemoryMonitor.h"
       
   116 
       
   117 
       
   118 
       
   119 // ===========================================================================
       
   120 // Constants
       
   121 
       
   122 // Sequence mode related constants that define the amount of pictures taken
       
   123 // with sequence mode.
       
   124 const TInt KShortBurstCount  = 18;   // number of images captured during burst
       
   125 
       
   126 // When asked if current memory is full in video mode
       
   127 // there needs to be at least following amount of recording
       
   128 // time left or memory is said to be full.
       
   129 const TTimeIntervalMicroSeconds KMemoryFullVideoRemaining = 1000*1000;
       
   130 
       
   131 // This is used to find the window group id for Eikon Server.
       
   132 // The Eikon Server window group id is later used to ignore all window server
       
   133 // events saying Eikon Server has gained focus.
       
   134 _LIT( KEikonServer, "EikonServer" );
       
   135 
       
   136 //const TCamMediaStorage KCamInternalStorage = ECamMediaStoragePhone;
       
   137 
       
   138 const TUint KCameraEventInterest = ( ECamCameraEventClassBasicControl
       
   139                                    | ECamCameraEventClassImage
       
   140                                    | ECamCameraEventClassVideo
       
   141                                    | ECamCameraEventClassVfControl
       
   142                                    | ECamCameraEventClassSsControl
       
   143                                    | ECamCameraEventClassSettings );
       
   144 
       
   145 
       
   146 
       
   147 // ===========================================================================
       
   148 // Member functions
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CCamAppUi::~CCamAppUi
       
   152 // Destructor
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 CCamAppUi::~CCamAppUi()
       
   156     {
       
   157     PRINT( _L("Camera => ~CCamAppUi" ))
       
   158     if ( iMemoryMonitor )
       
   159         {
       
   160         iMemoryMonitor->StopMonitoring();
       
   161         delete iMemoryMonitor;
       
   162         iMemoryMonitor = 0;
       
   163         }
       
   164 
       
   165     iController.SetAppUiAvailable( EFalse );
       
   166 
       
   167     iResourceLoaders.Close();
       
   168 
       
   169 #ifdef CAMERAAPP_DELAYED_POSTCAPTURE_CREATION
       
   170     if( iPostCapIdle )
       
   171         {
       
   172         iPostCapIdle->Cancel();
       
   173         delete iPostCapIdle;
       
   174         }
       
   175 #endif
       
   176 
       
   177     if ( iFileCheckAo )
       
   178         {
       
   179         iFileCheckAo->Cancel();
       
   180         delete iFileCheckAo;	
       
   181         }
       
   182 
       
   183     if ( iController.UiConfigManagerPtr()->IsOrientationSensorSupported() &&
       
   184          iSensorIdle )
       
   185         {
       
   186         CancelSensorIdle();
       
   187         delete iSensorIdle;
       
   188         }  
       
   189 
       
   190 #if !defined(__WINSCW__)
       
   191     // relinquish capture keys
       
   192     UnRegisterCaptureKeys();    
       
   193 #endif
       
   194 
       
   195     SaveCaptureMode();
       
   196     SaveCourtesyUiState();
       
   197 
       
   198     delete iDecoratedNaviPaneCounter;
       
   199     delete iDecoratedNaviPaneProgressBar;
       
   200 #if defined( CAMERAAPP_CAPI_V2_DVF )
       
   201     if ( iSelfTimer )
       
   202         {
       
   203         iSelfTimer->RemoveObserver( this );
       
   204         }
       
   205 #endif // CAMERAAPP_CAPI_V2_DVF
       
   206     delete iSelfTimer;
       
   207     delete iParentAppName;
       
   208     delete iTextResolver;
       
   209 
       
   210     iController.RemoveControllerObserver( this );
       
   211 
       
   212     // Burst mode observers are not owned, delete only the pointers to them.
       
   213     iBurstModeObservers.Close();
       
   214 
       
   215     if ( iWaitTimer && iWaitTimer->IsActive() )
       
   216         {
       
   217         iWaitTimer->Cancel();
       
   218         }
       
   219     delete iWaitTimer;
       
   220     delete iDocHandler;
       
   221     delete iCamSidePane;
       
   222     delete iCamZoomPane;       
       
   223 
       
   224     delete iRepository;
       
   225 
       
   226 /*#ifndef __WINSCW__
       
   227     delete iSFIUtils;
       
   228 #endif*/
       
   229 
       
   230     delete iNaviCounterControl;
       
   231     delete iNaviProgressBarControl;
       
   232     delete iNaviCounterModel;
       
   233     delete iNaviProgressBarModel;  
       
   234     delete iActivePaletteHandler;
       
   235     iActivePaletteHandler = NULL;
       
   236 
       
   237     if( iCourtesyTimer )
       
   238         {
       
   239         iCourtesyTimer->Cancel();
       
   240         }
       
   241     delete iCourtesyTimer;
       
   242     delete iScreenClearer;
       
   243     delete iVolumeKeyObserver;
       
   244 
       
   245     delete iCollectionManager;
       
   246     iCollectionManager = NULL;
       
   247 
       
   248     PRINT( _L("Camera <= ~CCamAppUi" ))
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CCamAppUi::ConstructL
       
   253 // Symbian 2nd phase constructor can leave.
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 void CCamAppUi::ConstructL()
       
   257   {
       
   258   OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP2_CCAMAPPUI_CONSTRUCTL, "e_CCamAppUi_ConstructL 1" );
       
   259   PRINT( _L("Camera => CCamAppUi::ConstructL") )
       
   260   iRotatedKeyEvent = ETrue;
       
   261   iReturnedFromPlugin = EFalse;
       
   262   iController.SetAppUiAvailable( ETrue );
       
   263 
       
   264   iLockedQwertyState = E2ndCamUnknown; 
       
   265   iMemoryMonitor = CCamMemoryMonitor::NewL( this, &iController );
       
   266 
       
   267   TInt memError =
       
   268   iMemoryMonitor->CheckAndRequestMemoryL( iController.UiConfigManagerPtr()->CriticalLevelRamMemory(),
       
   269                                           iController.UiConfigManagerPtr()->RequiredRamMemory(),
       
   270                                           ETrue );
       
   271 
       
   272 
       
   273   TInt freeMemory = 0;
       
   274   HAL::Get( HALData::EMemoryRAMFree, freeMemory );
       
   275   if ( memError && freeMemory < iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained() )
       
   276       {
       
   277       User::Leave( memError );
       
   278       }
       
   279   iUiConstructionComplete = EFalse;
       
   280   iDSASupported = iController.UiConfigManagerPtr()->IsDSAViewFinderSupported();
       
   281   
       
   282   TBool uiOrientationOverride = iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported();
       
   283   
       
   284   // Get the screenmode values used for setting  the orientation
       
   285   RArray<TInt> screenModeValues;
       
   286   if ( uiOrientationOverride )
       
   287       {
       
   288       iController.UiConfigManagerPtr()->SupportedScreenModesL( screenModeValues );
       
   289       iLandscapeScreenMode = screenModeValues[0];
       
   290       iPortraitScreenMode = screenModeValues[1];
       
   291       }
       
   292   
       
   293   // The embedded views are set after ConstructL completes
       
   294   // but the value is only of interest if the app is embedded
       
   295   iEmbeddedViewSet = !IsEmbedded();
       
   296   PRINT1( _L("Camera => CCamAppUi::ConstructL iEmbeddedViewSet:%d"), iEmbeddedViewSet );
       
   297   
       
   298   // In embedded case requesting new file without defined resolution
       
   299   // the 0*0 is interpreted as the default mms size resolution
       
   300   iRequestedNewFileResolution.SetSize( 0, 0 );
       
   301 
       
   302   // Camera window group id
       
   303   iMyWgId = iCoeEnv->RootWin().Identifier();
       
   304 
       
   305   // Get the id of Eikon Server window group
       
   306   iEikonServerWindowGroupId = iCoeEnv->WsSession().FindWindowGroupIdentifier(
       
   307     0,
       
   308     KEikonServer );
       
   309   
       
   310   CApaWindowGroupName::FindByAppUid(
       
   311     KBtNotifierServerUid,
       
   312     iCoeEnv->WsSession(),
       
   313     iBTServerWindowGroupId);
       
   314 
       
   315   CApaWindowGroupName::FindByAppUid(
       
   316     KPhoneAppUid,
       
   317     iCoeEnv->WsSession(),
       
   318     iPhoneAppWindowGroupId);
       
   319 
       
   320   PRINT( _L("Camera <> create new repository") );
       
   321   TInt crValue = 0;
       
   322   if( !iRepository )
       
   323     {
       
   324     iRepository = CRepository::NewL( KCRUidCameraappSettings ); 
       
   325     }
       
   326 
       
   327   // get softkey position
       
   328   CamUtility::GetPsiInt( ECamPsiSoftKeyPosition, iSoftkeyPosition );
       
   329   
       
   330   iCamOrientation = ReadCurrentDeviceOrientation();
       
   331   PRINT1( _L("Camera <> CurrentDeviceOrientation (%d)"), iCamOrientation )
       
   332   PERF_EVENT_START_L2( EPerfEventAvkonUIConstruction );  
       
   333   TInt orientation;
       
   334   if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() )
       
   335       {
       
   336       PRINT( _L("Camera <> using slider position to set orientation") );
       
   337       // Use the current slider position for the required orientation
       
   338       TInt sliderPosition;
       
   339       TInt err = RProperty::Get(
       
   340             CameraPlatPSKeys::KPSCameraPlatUid,
       
   341             CameraPlatPSKeys::KLensCoverStatus,
       
   342             sliderPosition );  
       
   343       
       
   344       // ToDo this could be removed after PCFW has released new implementation (wk25/2009)
       
   345       if( err == KErrNotFound )
       
   346           {
       
   347           PRINT( _L("Camera <> using slider position to set orientation") );
       
   348           err = RProperty::Get(
       
   349               NMusResourceApi::KCategoryUid,
       
   350               NMusResourceApi::KCameraAvailability,
       
   351               sliderPosition );  
       
   352           }
       
   353       PRINT2( _L("Camera <> slider position = %d, error = %d"),
       
   354             sliderPosition, err );
       
   355   
       
   356       // If there is an error then assume the slider is closed (as long as there is
       
   357       // more than one camera) 
       
   358       if ( err )
       
   359         {
       
   360         PRINT1( _L("Camera <> Slider status err%d - Check status later"),err )
       
   361         iController.SetCameraSwitchRequired( ESwitchToUnknown );
       
   362         }
       
   363       if ( ( ( CCamAppController::CamerasAvailable() > 1 && 
       
   364              sliderPosition == CameraPlatPSKeys::EClosed ) || 
       
   365            err != KErrNone ) && !IsQwerty2ndCamera( ETrue ) ) 
       
   366           {
       
   367           PRINT( _L("Camera <> setting orientation for secondary camera") )
       
   368           CamUtility::GetPsiInt( ECamPsiSecondaryCameraOrientation, orientation );
       
   369           }
       
   370       else
       
   371           {
       
   372           PRINT( _L("Camera <> setting orientation for primary camera") )
       
   373           CamUtility::GetPsiInt( ECamPsiPrimaryCameraOrientation, orientation );    
       
   374           } 
       
   375       }
       
   376   else
       
   377       {
       
   378       // Without lens cover support, always start to primary camera
       
   379       CamUtility::GetPsiInt( ECamPsiPrimaryCameraOrientation, orientation );
       
   380       }
       
   381 
       
   382   // Finish engine construction    
       
   383   if( uiOrientationOverride )
       
   384     {
       
   385     iController.CompleteConstructionL();
       
   386     }
       
   387 
       
   388   if ( orientation == ( TInt ) EAppUiOrientationLandscape )
       
   389     {
       
   390     PRINT( _L("Camera <> orientation is landscape ") )
       
   391     iCamOrientation = (ECamHandLeft == iSoftkeyPosition ) 
       
   392                     ? ECamOrientationCamcorderLeft 
       
   393                     : ECamOrientationCamcorder;
       
   394     if( uiOrientationOverride )
       
   395       {
       
   396       //set orientation to CCamera	
       
   397       iController.SetCameraOrientationModeL( iLandscapeScreenMode );
       
   398       // and complete the cameracontroller construction
       
   399       iController.CompleteCameraConstructionL();
       
   400       }
       
   401     PRINT( _L("Camera <> Calling BaseConstructL") )
       
   402     OstTrace0( CAMERAAPP_PERFORMANCE, CCAMAPPUI_CONSTRUCTL, "e_CAM_APP_BASE_CONSTRUCT 1" ); //CCORAPP_APP_BASE_CONSTRUCT_START
       
   403     BaseConstructL( EAppOrientationLandscape | EAknEnableSkin | EAknEnableMSK | 
       
   404                     ENonStandardResourceFile | EAknSingleClickCompatible );
       
   405     OstTrace0( CAMERAAPP_PERFORMANCE, DUP1_CCAMAPPUI_CONSTRUCTL, "e_CAM_APP_BASE_CONSTRUCT 0" );    //CCORAPP_APP_BASE_CONSTRUCT_END
       
   406     PRINT( _L("Camera <> BaseConstructL Complete") )
       
   407     }
       
   408   else
       
   409     {
       
   410     PRINT( _L("Camera <> orientation is portrait") )
       
   411     iCamOrientation = ECamOrientationPortrait;
       
   412     if( uiOrientationOverride )
       
   413       {
       
   414       //set orientation to CCamera	
       
   415       iController.SetCameraOrientationModeL( iPortraitScreenMode );
       
   416       // and complete the cameracontroller construction
       
   417       iController.CompleteCameraConstructionL();
       
   418       }     
       
   419     PRINT( _L("Camera <> Calling BaseConstructL") )
       
   420     OstTrace0( CAMERAAPP_PERFORMANCE, DUP4_CCAMAPPUI_CONSTRUCTL, "e_CAM_APP_BASE_CONSTRUCT 1" );
       
   421     BaseConstructL( EAppOrientationPortrait | EAknEnableSkin | EAknEnableMSK | 
       
   422                     ENonStandardResourceFile );  
       
   423     OstTrace0( CAMERAAPP_PERFORMANCE, DUP5_CCAMAPPUI_CONSTRUCTL, "e_CAM_APP_BASE_CONSTRUCT 0" );
       
   424     PRINT( _L("Camera <> BaseConstructL Complete") )
       
   425     }
       
   426 
       
   427     PERF_EVENT_END_L2( EPerfEventAvkonUIConstruction );
       
   428 
       
   429 #if !defined (__WINSCW__)
       
   430 #if !( defined(__WINS__) || defined(__WINSCW__) )
       
   431   // Ensure that the macro switch keys are always captured by this
       
   432   // application.
       
   433   if ( !AppInBackground( EFalse ) )  //camera is constructed in background
       
   434      {
       
   435       RegisterCaptureKeysL();
       
   436      }
       
   437 #endif // !defined(__WINS__) || defined(__WINSCW__)    
       
   438 #endif
       
   439 
       
   440   if( !uiOrientationOverride )
       
   441     {
       
   442     // Load the settings model static settings
       
   443     PRINT( _L("Camera <> call CCamAppController::LoadStaticSettingsL..") )
       
   444     iController.LoadStaticSettingsL( IsEmbedded() );
       
   445   
       
   446     // Check the screen size if it matches the orientation we expect.
       
   447     // If not, delay the initialization until HandleScreenDeviceChangedL is called.
       
   448     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP6_CCAMAPPUI_CONSTRUCTL, "e_ReadUiOrientationFromWindowServer 1" );
       
   449     TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
   450     PRINT2( _L("<> CCamAppUi::ConstructL() iCoeEnv->ScreenDevice()->SizeInPixels():  w=%d h=%d"), screenSize.iWidth, screenSize.iHeight );
       
   451     TBool expectLandscape = (iCamOrientation != ECamOrientationPortrait);
       
   452     TBool isLandscape     = (screenSize.iWidth > screenSize.iHeight);
       
   453     if( isLandscape != expectLandscape || AppInBackground( EFalse ) )   //screen is not ready or camera app is in background
       
   454       {
       
   455       iEngineConstructionDelayed = ETrue;
       
   456       }
       
   457 
       
   458 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP7_CCAMAPPUI_CONSTRUCTL, "e_ReadUiOrientationFromWindowServer 0" );
       
   459 
       
   460     // initialise the self timer mode 
       
   461     iInSelfTimerMode = ECamSelfTimerDisabled;
       
   462 
       
   463     if ( !iEngineConstructionDelayed )     
       
   464       {
       
   465     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP8_CCAMAPPUI_CONSTRUCTL, "e_EngineConstructionDelayed 1" );
       
   466       iController.CompleteConstructionL();
       
   467       iController.StoreUserSceneSettingsL();
       
   468     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP9_CCAMAPPUI_CONSTRUCTL, "e_EngineConstructionDelayed 0" );
       
   469 
       
   470       } 
       
   471     }
       
   472   else
       
   473     {
       
   474     iEngineConstructionDelayed = EFalse;    
       
   475     iInSelfTimerMode = ECamSelfTimerDisabled;
       
   476     }
       
   477   
       
   478   
       
   479   iEmbeddedObserver = NULL;
       
   480   
       
   481   iController.AddControllerObserverL( this );
       
   482   iController.AddCameraObserverL( this, KCameraEventInterest );
       
   483   
       
   484   if( !uiOrientationOverride )
       
   485     {
       
   486 /*#ifndef __WINSCW__
       
   487     // Initialize SFIUtils
       
   488   OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP10_CCAMAPPUI_CONSTRUCTL, "e_InitSendFileInCall 1" );
       
   489 	PRINT(_L("iSFIUtils = CSFIUtilsAppInterface::NewL -->"));
       
   490     TRAPD(errSFI,iSFIUtils = CSFIUtilsAppInterface::NewL());
       
   491 	PRINT1(_L("iSFIUtils = CSFIUtilsAppInterface::NewL <-- errSFI=%d"),errSFI);
       
   492 	User::LeaveIfError(errSFI);
       
   493     iSendFileInCall = EFalse;
       
   494   OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP11_CCAMAPPUI_CONSTRUCTL, "e_InitSendFileInCall 0" );
       
   495     PRINT( _L("iSendFileInCall = EFalse") );
       
   496 #endif*/
       
   497 
       
   498     // Create text resolver for error note text
       
   499     iTextResolver = CTextResolver::NewL();
       
   500 
       
   501     ConstructPreCaptureViewsL();
       
   502   
       
   503     iSelfTimer = CCamSelfTimer::NewL( iController );
       
   504 #if defined( CAMERAAPP_CAPI_V2_DVF )
       
   505     iSelfTimer->AddObserverL( this ); 
       
   506 #endif // CAMERAAPP_CAPI_V2_DVF
       
   507 
       
   508     PRINT( _L("Camera <> creating navicounter model") );
       
   509     iNaviCounterModel = CCamNaviCounterModel::NewL( iController );
       
   510     PRINT( _L("Camera <> append navicounter to resourceloaders") );
       
   511     User::LeaveIfError( iResourceLoaders.Append(iNaviCounterModel) );
       
   512   
       
   513     PRINT( _L("Camera <> creating progress bar model") );
       
   514     iNaviProgressBarModel = CCamNaviProgressBarModel::NewL( iController );
       
   515     PRINT( _L("Camera <> append progressbar to resourceloaders") );
       
   516     User::LeaveIfError(iResourceLoaders.Append(iNaviProgressBarModel));
       
   517   
       
   518     ConstructNaviPaneL();
       
   519     }
       
   520 
       
   521   
       
   522   iRepository->Get( KCamCrAlwaysDrawCourtesyUi, crValue );
       
   523   iAlwaysDrawPreCaptureCourtesyUI = (crValue == KCamCrAlwaysDrawCourtesyUiIsOn);
       
   524 
       
   525   iCoeEnv->RootWin().EnableScreenChangeEvents();
       
   526 
       
   527 
       
   528   if( uiOrientationOverride )
       
   529     {
       
   530     // always start in still mode	
       
   531     iMode = ECamControllerImage;
       
   532     iTargetMode = ECamControllerImage;	
       
   533     }
       
   534   else
       
   535     {  
       
   536     // If the view launch needs to wait until the engine
       
   537     // is constructed or the embedded launch view is set, the starting
       
   538     // state will be standby    
       
   539     if ( !IsConstructionComplete() )
       
   540       {
       
   541       iViewState = ECamViewStateStandby;
       
   542       }
       
   543 
       
   544     // Get start up mode from settings.
       
   545     // If the application is embedded the new view will be set
       
   546     // when HandleNewFileL is called by the framework
       
   547     PRINT( _L("Camera <> CCamAppUi::ConstructL set default view") );
       
   548     if ( StartupMode() == ECamStillCapture )
       
   549       {
       
   550       iMode = ECamControllerImage;
       
   551       iTargetMode = ECamControllerImage;
       
   552       SetDefaultViewL( *iStillCaptureView );
       
   553       }
       
   554     else
       
   555       {
       
   556       iMode = ECamControllerVideo;
       
   557       iTargetMode = ECamControllerVideo;
       
   558       SetDefaultViewL( *iVideoCaptureView );
       
   559       }      
       
   560 
       
   561 
       
   562     if( !iEngineConstructionDelayed )
       
   563       {
       
   564       // pre-construct side-pane & zoom pane
       
   565       // get whether we overlay sidepane over view-finder
       
   566       TBool overlayViewFinder;
       
   567       User::LeaveIfError( CamUtility::GetPsiInt( ECamPsiOverLaySidePane, overlayViewFinder ) );
       
   568       PRINT( _L("Camera <> CCamAppUi::ConstructL create sidepane") );
       
   569       iCamSidePane = CCamSidePane::NewL( iController, overlayViewFinder );
       
   570       User::LeaveIfError(iResourceLoaders.Append(iCamSidePane));
       
   571     
       
   572       PRINT( _L("Camera <> CCamAppUi::ConstructL create zoom pane") );
       
   573       iCamZoomPane = CCamZoomPane::NewL( iController, overlayViewFinder );
       
   574       User::LeaveIfError(iResourceLoaders.Append(iCamZoomPane));
       
   575       }
       
   576   }  
       
   577   // create the timer used for callbacks
       
   578   iWaitTimer = CPeriodic::NewL( CActive::EPriorityHigh );
       
   579 
       
   580  
       
   581   // initialise the view construction states
       
   582   iPostCaptureViewsConstructed     = EFalse;
       
   583   iUserSceneSetupViewConstructed   = EFalse;
       
   584   iCustomiseToolbarViewConstructed = EFalse;
       
   585   
       
   586   if( !uiOrientationOverride )
       
   587     {  
       
   588     PRINT( _L("Camera => CCamAppUi::ConstructL create doc handler") );
       
   589     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
       
   590   iController.CheckMemoryToUseL();
       
   591   
       
   592     // create navi-pane and navi-porgress bar for use in camcorder mode 
       
   593     PRINT( _L("Camera => CCamAppUi::ConstructL create navicounter control") );
       
   594     iNaviCounterControl = CCamNaviCounterControl::NewL( *iNaviCounterModel );
       
   595     iNaviCounterControl->SetExtentToWholeScreen();
       
   596   
       
   597     PRINT( _L("Camera => CCamAppUi::ConstructL create progress bar control") );
       
   598     iNaviProgressBarControl = CCamNaviProgressBarControl::NewL( *iNaviProgressBarModel );        
       
   599   
       
   600     // get max num of images for burst capture
       
   601     CamUtility::GetPsiInt( ECamPsiMaxBurstCapture, iMaxBurstCaptureNum );
       
   602   
       
   603     PRINT( _L("Camera => CCamAppUi::ConstructL create AP handler") );
       
   604     iActivePaletteHandler = CCamActivePaletteHandler::NewL( iController, EFalse );
       
   605     }
       
   606       
       
   607   iDrawPreCaptureCourtesyUI = ETrue;
       
   608   iDrawPostCaptureCourtesyUI = ETrue;
       
   609   iAlwaysDrawPostCaptureCourtesyUI = ETrue;
       
   610   iLeftSoftKeyPressed = EFalse;
       
   611   if( !uiOrientationOverride )
       
   612     {
       
   613     // get coutesy UI timeout
       
   614     TInt timeoutValue;
       
   615     CamUtility::GetPsiInt( ECamPsiCourtesyUiTimeoutValue, timeoutValue );
       
   616   
       
   617     iCourtesyTimer = CCamTimer::NewL( timeoutValue * 1000000, 
       
   618                                       TCallBack( CCamAppUi::CourtesyTimeout, this ) );
       
   619 
       
   620     PRINT( _L("Camera => CCamAppUi::ConstructL update navi models") );
       
   621     UpdateNaviModelsL();
       
   622     PRINT( _L("Camera => CCamAppUi::ConstructL navi counter reload resources") );
       
   623     iNaviCounterModel->ReloadResourceDataL();
       
   624     PRINT( _L("Camera => CCamAppUi::ConstructL navi progress bar reload resources") );
       
   625     iNaviProgressBarModel->ReloadResourceDataL();
       
   626     }
       
   627       
       
   628   iZoomPaneShown = EFalse;
       
   629   iFirstBoot = ETrue; // Show zoom
       
   630   iProcessingScreenRedraw = EFalse;
       
   631   iSendAsInProgress = EFalse;
       
   632   
       
   633   if( !uiOrientationOverride )
       
   634     {  
       
   635     iFileCheckAo = CCamFileCheckAo::NewL( iController, *this );  
       
   636     iCollectionManager = new (ELeave) CCamCollectionManagerAO( *this );
       
   637     }
       
   638 
       
   639   iCheckOperationInProgress = EFalse;
       
   640   iLostFocusToNewWindow = EFalse;
       
   641   iFirstVFStart = ETrue;
       
   642 
       
   643   iInternalStorage = iController.ExistMassStorage()?ECamMediaStorageMassStorage:ECamMediaStoragePhone;
       
   644 
       
   645   if ( !uiOrientationOverride )
       
   646     {
       
   647     iUiConstructionComplete = ETrue;
       
   648     }
       
   649   iMemoryMonitor->StartMonitoring( iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained(),
       
   650                                    iController.UiConfigManagerPtr()->RequiredRamMemoryFocusGained() );
       
   651   PRINT( _L("Camera <= CCamAppUi::ConstructL") )
       
   652   OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP3_CCAMAPPUI_CONSTRUCTL, "e_CCamAppUi_ConstructL 0" );
       
   653   }
       
   654     
       
   655 
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // IsInternalView
       
   659 // -----------------------------------------------------------------------------
       
   660 //
       
   661 TBool CCamAppUi::IsInternalView( TCamViewState aViewState ) const
       
   662   {
       
   663   PRINT1( _L("Camera => CCamAppUi::IsInternalView [%s]"), KCamViewStateNames[aViewState] );
       
   664 
       
   665   TBool internal( EFalse );
       
   666 
       
   667   if ( aViewState < ECamViewStateRangeInternalMax
       
   668     && aViewState > ECamViewStateRangeInternalMin )
       
   669       {
       
   670       internal = ETrue;
       
   671       }
       
   672   else if( aViewState < ECamViewStateRangeExternalMax
       
   673         && aViewState > ECamViewStateRangeExternalMin )
       
   674       {
       
   675       internal = EFalse;
       
   676       }
       
   677   else
       
   678     {
       
   679     CamPanic( ECamPanicInvalidView );
       
   680     }
       
   681 
       
   682   PRINT1( _L("Camera <= CCamAppUi::IsInternalView, return %d"), internal );
       
   683   return internal;
       
   684   }
       
   685 
       
   686 
       
   687  
       
   688 // -----------------------------------------------------------------------------
       
   689 // CCamAppUi::IsConstructionComplete
       
   690 // Returns whether or not all construction has completed
       
   691 // -----------------------------------------------------------------------------
       
   692 //    
       
   693 TBool CCamAppUi::IsConstructionComplete() const
       
   694     {     
       
   695     TBool complete = ETrue;
       
   696     complete = !iEngineConstructionDelayed;
       
   697     return complete && iEmbeddedViewSet; 
       
   698     }
       
   699 
       
   700     
       
   701 // -----------------------------------------------------------------------------
       
   702 // CCamAppUi::NaviCounter
       
   703 // Returns the pointer to the NaviCounter control
       
   704 // -----------------------------------------------------------------------------
       
   705 //
       
   706 CCamNaviCounterControl* CCamAppUi::NaviCounterControl()
       
   707     {
       
   708     return iNaviCounterControl;
       
   709     }
       
   710     
       
   711 // -----------------------------------------------------------------------------
       
   712 // CCamAppUi::NaviProgressBar
       
   713 // Returns the pointer to the NaviProgress control
       
   714 // -----------------------------------------------------------------------------
       
   715 //
       
   716 CCamNaviProgressBarControl* CCamAppUi::NaviProgressBarControl()
       
   717     {
       
   718     return iNaviProgressBarControl;
       
   719     }
       
   720 
       
   721 // -----------------------------------------------------------------------------
       
   722 // CCamAppUi::NaviCounterModel
       
   723 // Returns the pointer to the NaviCounter model
       
   724 // -----------------------------------------------------------------------------
       
   725 //    
       
   726 CCamNaviCounterModel* CCamAppUi::NaviCounterModel()
       
   727     {
       
   728     return iNaviCounterModel;
       
   729     }
       
   730 
       
   731 
       
   732 // -----------------------------------------------------------------------------
       
   733 // CCamAppUi::CCamAppUi
       
   734 // C++ default constructor can NOT contain any code, that
       
   735 // might leave.
       
   736 // -----------------------------------------------------------------------------
       
   737 //
       
   738 CCamAppUi::CCamAppUi( CCamAppController& aController )                              
       
   739     : iController( aController ),
       
   740     iViewState( ECamViewStatePreCapture ),
       
   741     iTargetViewState( ECamViewStatePreCapture ), 
       
   742     iPreventActivePaletteDisplay( EFalse ),
       
   743     iInternalStorage(ECamMediaStorageNone)
       
   744     {
       
   745     }
       
   746 
       
   747 // ----------------------------------------------------
       
   748 // CCamAppUi::SetTitleL
       
   749 // Set title pane text from a resource.
       
   750 // ----------------------------------------------------
       
   751 //
       
   752 void CCamAppUi::SetTitleL( TInt aResourceId )
       
   753     {
       
   754     // Set title
       
   755     CAknTitlePane* title = static_cast<CAknTitlePane*>(
       
   756         StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   757     TResourceReader reader;
       
   758     iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
       
   759     title->SetFromResourceL( reader );
       
   760     CleanupStack::PopAndDestroy();  // resource reader
       
   761     }
       
   762 
       
   763 // ----------------------------------------------------
       
   764 // CCamAppUi::SetTitleL
       
   765 // Set title pane text from a descriptor.
       
   766 // ----------------------------------------------------
       
   767 //
       
   768 void CCamAppUi::SetTitleL( const TDesC& aText )
       
   769     {
       
   770     CAknTitlePane* title = static_cast<CAknTitlePane*>(
       
   771         StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   772     title->SetTextL( aText );
       
   773     }
       
   774 
       
   775 
       
   776 
       
   777 // ----------------------------------------------------
       
   778 // CCamAppUi::PushNaviPaneCounterL
       
   779 // Push navi pane counter on to navi pane stack.
       
   780 // ----------------------------------------------------
       
   781 //
       
   782 void 
       
   783 CCamAppUi::PushNaviPaneCounterL()
       
   784   {
       
   785   iNaviCounterModel->SetCaptureModeL( iMode, iImageMode );
       
   786   iDecoratedNaviPaneCounter->MakeScrollButtonVisible( EFalse );
       
   787   NaviPaneL()->PushL( *iDecoratedNaviPaneCounter );
       
   788   }
       
   789 
       
   790 // ----------------------------------------------------
       
   791 // CCamAppUi::PushNaviPaneProgressBarL
       
   792 // Push navi pane progress bar on to navi pane stack.
       
   793 // ----------------------------------------------------
       
   794 //
       
   795 void CCamAppUi::PushNaviPaneProgressBarL()
       
   796     {
       
   797     iDecoratedNaviPaneProgressBar->MakeScrollButtonVisible( EFalse );
       
   798     NaviPaneL()->PushL( *iDecoratedNaviPaneProgressBar );
       
   799     }
       
   800 
       
   801 // ----------------------------------------------------
       
   802 // CCamAppUi::PushDefaultNaviPaneL
       
   803 // Push default navi pane on to navi pane stack.
       
   804 // ----------------------------------------------------
       
   805 //
       
   806 void CCamAppUi::PushDefaultNaviPaneL()
       
   807     {
       
   808     NaviPaneL()->PushDefaultL();
       
   809     }
       
   810 
       
   811 
       
   812 // ----------------------------------------------------
       
   813 // CCamAppUi::DisplayDeleteNoteL
       
   814 // Call DisplayDeleteNoteL on the current view
       
   815 // ----------------------------------------------------
       
   816 //
       
   817 TBool CCamAppUi::DisplayDeleteNoteL()
       
   818   {
       
   819   TBool deleted = 
       
   820           static_cast<CCamPostCaptureViewBase*>( iView )->DisplayDeleteNoteL();
       
   821 
       
   822   // If the image/video has been deleted, switch view
       
   823   if ( deleted )
       
   824     {
       
   825                               
       
   826     if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() && IsEmbedded() )
       
   827         {
       
   828         // if in embedded mode, then check the status of the slide
       
   829         // and set a pending camera switch if the slide has been
       
   830         // opened/closed after starting the capture
       
   831         iController.CheckSlideStatus();
       
   832         }      
       
   833                                
       
   834     // if this is burst mode and there are still images left, 
       
   835     // return to thumbnail view
       
   836     if ( ECamImageCaptureBurst == iController.CurrentImageModeSetup()
       
   837       && 0                     <  iController.CurrentItemCount() )
       
   838       {
       
   839       iTargetViewState = ECamViewStateBurstThumbnail;
       
   840       }
       
   841     // otherwise switch to pre-capture view
       
   842     else
       
   843       {
       
   844       iTargetViewState = ECamViewStatePreCapture;
       
   845       }
       
   846     TrySwitchViewL();
       
   847     }
       
   848   else
       
   849     {
       
   850     }
       
   851   return deleted;
       
   852   }
       
   853 
       
   854 // ----------------------------------------------------
       
   855 // CCamAppUi::SelfTimerEnableL
       
   856 // Enable or disable SelfTimer functionality
       
   857 // ----------------------------------------------------
       
   858 //
       
   859 void CCamAppUi::SelfTimerEnableL( TCamSelfTimerFunctions aState )
       
   860     {
       
   861     // If the requested state is the current state, do nothing.
       
   862     if ( iInSelfTimerMode == aState )
       
   863         {
       
   864         return;
       
   865         }
       
   866 
       
   867     __ASSERT_DEBUG( iSelfTimer, CamPanic( ECamPanicNullPointer ) );
       
   868 
       
   869     // Update the member variable
       
   870     iInSelfTimerMode = aState;
       
   871 
       
   872     if ( aState != ECamSelfTimerDisabled  )
       
   873         {     
       
   874         // Set up for current timer mode
       
   875         iSelfTimer->SetModeL( iMode, iImageMode, iInSelfTimerMode );              
       
   876         UpdateCba();
       
   877         }
       
   878     else                
       
   879         {
       
   880         // stop the timer and remove the indicator from the side pane
       
   881         iSelfTimer->Cancel();
       
   882 
       
   883         // In capture setup mode, toolbar and indicators are not visible
       
   884         // They will be updated when returning to precap, similarily to
       
   885         // when setting the self timer mode above
       
   886         if( iPreCaptureMode != ECamPreCapCaptureSetup )
       
   887             {
       
   888             // Re-show the active palette
       
   889             iActivePaletteHandler->UpdateActivePaletteL();
       
   890             iPreventActivePaletteDisplay = EFalse;
       
   891             SetActivePaletteVisibility( ETrue );
       
   892             
       
   893             if ( iController.IsTouchScreenSupported() )
       
   894                 {
       
   895                 CAknToolbar* toolbar = CurrentFixedToolbar();
       
   896                 if (toolbar)
       
   897                     {
       
   898                     toolbar->SetToolbarVisibility( ETrue );
       
   899                     }
       
   900                 }
       
   901             // Cancel any active focusing operation
       
   902             // this won't cancel if capture has already been requested
       
   903             iController.CancelFocusAndCapture();
       
   904                 
       
   905             iStillCaptureView->UpdateToolbarIconsL();
       
   906             
       
   907             // Raise precapture UI and restart courtesy UI timer,
       
   908             // if hide icons is enabled.
       
   909             RaisePreCaptureCourtesyUI(EFalse);        
       
   910             }        
       
   911         
       
   912         UpdateCba();
       
   913         }    
       
   914     }
       
   915 
       
   916 // -----------------------------------------------------------------------------
       
   917 // CCamAppUi::SelfTimerEnabled
       
   918 // Returns current self-timer state
       
   919 // -----------------------------------------------------------------------------
       
   920 //        
       
   921 TBool CCamAppUi::SelfTimerEnabled() const
       
   922     {
       
   923     return ( iInSelfTimerMode != ECamSelfTimerDisabled );
       
   924     }
       
   925 
       
   926 // -----------------------------------------------------------------------------
       
   927 // CCamAppUi::SelfTimer
       
   928 // Returns pointer to self-timer object
       
   929 // -----------------------------------------------------------------------------
       
   930 //        
       
   931 CCamSelfTimer* CCamAppUi::SelfTimer()
       
   932     {
       
   933     return iSelfTimer;
       
   934     }
       
   935 
       
   936 // -----------------------------------------------------------------------------
       
   937 // CCamAppUi::AddBurstModeObserverL
       
   938 // Register an observer for burst mode changes
       
   939 // -----------------------------------------------------------------------------
       
   940 // 
       
   941 void 
       
   942 CCamAppUi::AddBurstModeObserverL( MCamBurstModeObserver* aBurstModeObserver )
       
   943   {
       
   944   // Check for non-null and only add once.
       
   945   if( aBurstModeObserver &&
       
   946      KErrNotFound == iBurstModeObservers.Find( aBurstModeObserver ) )
       
   947     {
       
   948     iBurstModeObservers.AppendL( aBurstModeObserver );
       
   949     }
       
   950   }
       
   951 
       
   952 // -----------------------------------------------------------------------------
       
   953 // CCamAppUi::RemoveBurstModeObserver
       
   954 // Remove the burst mode observer
       
   955 // -----------------------------------------------------------------------------
       
   956 //
       
   957 void
       
   958 CCamAppUi::RemoveBurstModeObserver( const MCamBurstModeObserver* aBurstModeObserver )
       
   959   {
       
   960   if( aBurstModeObserver )
       
   961     {
       
   962     TInt index = iBurstModeObservers.Find( aBurstModeObserver );
       
   963     if( KErrNotFound != index )
       
   964       {
       
   965       iBurstModeObservers.Remove( index );
       
   966       }
       
   967     }
       
   968   }
       
   969 
       
   970 // -----------------------------------------------------------------------------
       
   971 // CCamAppUi::IsBurstEnabled
       
   972 // Return burst mode enabled state
       
   973 // -----------------------------------------------------------------------------
       
   974 //
       
   975 TBool CCamAppUi::IsBurstEnabled() const
       
   976   {
       
   977   PRINT_FRQ( _L("Camera => CCamAppUi::IsBurstEnabled" ) )
       
   978   TBool ret = EFalse;
       
   979   if ( ECamImageCaptureBurst     == iImageMode 
       
   980     || ECamImageCaptureTimeLapse == iImageMode )
       
   981     {
       
   982     ret = ETrue;
       
   983     }
       
   984 
       
   985   PRINT_FRQ( _L("Camera <= CCamAppUi::IsBurstEnabled" ) )
       
   986   return ret;
       
   987   }
       
   988     
       
   989 // -----------------------------------------------------------------------------
       
   990 // CCamAppUi::CurrentBurstMode
       
   991 // Return burst mode enabled type
       
   992 // -----------------------------------------------------------------------------
       
   993 // 
       
   994 TCamImageCaptureMode CCamAppUi::CurrentBurstMode() const
       
   995   {
       
   996   PRINT_FRQ( _L("Camera => CCamAppUi::CurrentBurstMode" ) )
       
   997   TCamImageCaptureMode mode( ECamImageCaptureNone );
       
   998 
       
   999   if ( ECamImageCaptureBurst     == iImageMode
       
  1000     || ECamImageCaptureTimeLapse == iImageMode )
       
  1001     {
       
  1002     mode = iImageMode;
       
  1003     }
       
  1004 
       
  1005   PRINT_FRQ( _L("Camera <= CCamAppUi::CurrentBurstMode" ) )
       
  1006   return mode;
       
  1007   }   
       
  1008 
       
  1009 
       
  1010 // -----------------------------------------------------------------------------
       
  1011 // CCamAppUi::IsSecondCameraEnabled
       
  1012 // Returns whether or the secondary camera has been activated
       
  1013 // Will return ETrue when when the second camera is active
       
  1014 // -----------------------------------------------------------------------------
       
  1015 //
       
  1016 TBool CCamAppUi::IsSecondCameraEnabled() const
       
  1017     {
       
  1018     PRINT_FRQ( _L("Camera =><= CCamAppUi::IsSecondCameraEnabled" ))
       
  1019     return iController.ActiveCamera() == ECamActiveCameraSecondary;
       
  1020     }
       
  1021 
       
  1022 // -----------------------------------------------------------------------------
       
  1023 // CCamAppUi::IsQwerty2ndCamera
       
  1024 // -----------------------------------------------------------------------------
       
  1025 //
       
  1026 TBool CCamAppUi::IsQwerty2ndCamera( TBool aLock )
       
  1027     {
       
  1028     TBool ret = EFalse;
       
  1029     if ( aLock )
       
  1030         {
       
  1031         iLockedQwertyState = E2ndCamUnknown;
       
  1032         }
       
  1033 
       
  1034     switch( iLockedQwertyState )
       
  1035         {
       
  1036         case E2ndCamPortraitForced: 
       
  1037             {
       
  1038             ret = EFalse; 
       
  1039             break;
       
  1040             }
       
  1041         case E2ndCamLandscapeForced:     
       
  1042             {
       
  1043             ret = ETrue; 
       
  1044             break;
       
  1045             }
       
  1046         case E2ndCamUnknown:     
       
  1047             {
       
  1048             // Get variant setting i.e. initialize
       
  1049             TInt value = 0;
       
  1050             if ( iController.UiConfigManagerPtr() )
       
  1051                {
       
  1052             	value = iController.UiConfigManagerPtr()->IsQwerty2ndCamera();
       
  1053                 
       
  1054                 iLockedQwertyState = static_cast<T2ndCamOrientation>(value); 
       
  1055                 if ( iLockedQwertyState == E2ndCamAuto )
       
  1056                     {
       
  1057                     ret = CamUtility::IsQwertyOpen(); 
       
  1058                     }
       
  1059                 else
       
  1060                     {
       
  1061                     ret = iLockedQwertyState == E2ndCamLandscapeForced;
       
  1062                     }
       
  1063  		}            
       
  1064             break;
       
  1065             }
       
  1066         case E2ndCamAuto:
       
  1067             {
       
  1068             ret = CamUtility::IsQwertyOpen(); 
       
  1069             break;
       
  1070             }
       
  1071         default: 
       
  1072             break;
       
  1073         }
       
  1074 
       
  1075     if ( aLock )
       
  1076         {
       
  1077         iLockedQwertyState = ret?E2ndCamLandscapeForced:E2ndCamPortraitForced;
       
  1078         }
       
  1079 
       
  1080     return ret;
       
  1081     }
       
  1082 
       
  1083 // -----------------------------------------------------------------------------
       
  1084 // CCamAppUi::IsWaitDialog
       
  1085 // -----------------------------------------------------------------------------
       
  1086 //
       
  1087 TBool CCamAppUi::IsWaitDialog() const
       
  1088   {
       
  1089   return iWaitDialog != NULL;
       
  1090   }
       
  1091 
       
  1092 // -----------------------------------------------------------------------------
       
  1093 // CCamAppUi::ActiveCamera
       
  1094 // Returns the active camera
       
  1095 // -----------------------------------------------------------------------------
       
  1096 //
       
  1097 TCamActiveCamera CCamAppUi::ActiveCamera() const
       
  1098   {
       
  1099   return iController.ActiveCamera();
       
  1100   }
       
  1101     
       
  1102 // -----------------------------------------------------------------------------
       
  1103 // CCamAppUi::HandleCommandL
       
  1104 // Handle user menu selections
       
  1105 // -----------------------------------------------------------------------------
       
  1106 //
       
  1107 void CCamAppUi::HandleCommandL( TInt aCommand )
       
  1108   {
       
  1109   PRINT1( _L("Camera => CCamAppUi::HandleCommandL (%d)"), aCommand )
       
  1110   switch( aCommand )
       
  1111     {       
       
  1112     // -----------------------------------------------------
       
  1113     case ECamCmdRaiseCourtesyUI:
       
  1114       {            
       
  1115       if ( ECamViewStatePreCapture == iViewState )
       
  1116         {
       
  1117         RaisePreCaptureCourtesyUI(EFalse);
       
  1118         }
       
  1119       else if ( ECamViewStatePostCapture == iViewState )
       
  1120         {
       
  1121         // iLeftSoftKeyPressed resembles the Left SoftKey(LSK) 
       
  1122         // press when AP tool bar is hidden
       
  1123 
       
  1124         if ( iLeftSoftKeyPressed )
       
  1125         	{
       
  1126         	// LSK is pressed, we raise the AP tool bar
       
  1127         	RaisePostCaptureCourtesyUI();
       
  1128         	}
       
  1129         else
       
  1130         	{
       
  1131         	// RSK is pressed, we return back to PreCaptureView
       
  1132         	HandleCommandL( EAknSoftkeyBack );	
       
  1133         	}
       
  1134         
       
  1135         }
       
  1136       else
       
  1137         {
       
  1138         }
       
  1139       }
       
  1140       break;
       
  1141 
       
  1142     // -----------------------------------------------------
       
  1143     case ECamCmdSceneSettingList:
       
  1144       {
       
  1145       iTargetViewState = ECamViewStateSceneSettingList;
       
  1146       TrySwitchViewL();
       
  1147       }
       
  1148       break;
       
  1149     // -----------------------------------------------------
       
  1150     case ECamCmdGoToStandby:
       
  1151       {
       
  1152       CAknTitlePane* title = static_cast<CAknTitlePane*>
       
  1153                              ( StatusPane()->ControlL( TUid::Uid ( EEikStatusPaneUidTitle ) ) );
       
  1154 
       
  1155       title->SetTextL( _L("") ); 
       
  1156       title->MakeVisible( ETrue ); 
       
  1157       title->DrawNow(); 
       
  1158       SetActivePaletteVisibility( EFalse );
       
  1159 
       
  1160       if ( iView 
       
  1161           && ( iStillCaptureView == iView || iVideoCaptureView == iView ) )
       
  1162           {
       
  1163           iProcessingScreenRedraw = ETrue;
       
  1164           static_cast<CCamPreCaptureViewBase*>( iView )->Container()->DrawNow();
       
  1165           iProcessingScreenRedraw = EFalse;
       
  1166           }
       
  1167 
       
  1168       PRINT1( _L("CCamAppUi::HandleCommandL standby %d"), iViewState );            
       
  1169       iTargetViewState = ECamViewStateStandby;
       
  1170       TrySwitchViewL();
       
  1171       }
       
  1172       break;
       
  1173     // -----------------------------------------------------
       
  1174     case ECamCmdSwitchToPrecapture:
       
  1175       {
       
  1176       iTargetViewState = ECamViewStatePreCapture;
       
  1177       TrySwitchViewL();
       
  1178       }
       
  1179       break;
       
  1180     // -----------------------------------------------------
       
  1181     case ECamCmdNewPhoto:
       
  1182       {
       
  1183 	  if ( !iController.IsViewFinding() && iController.EngineRequestsPending() ) 
       
  1184 	    {	
       
  1185 		return;
       
  1186 	    }
       
  1187       // check if currently preparing return
       
  1188       if ( iController.CaptureModeTransitionInProgress() )
       
  1189         {
       
  1190         return;
       
  1191         }
       
  1192       #ifdef CAMERAAPP_PERFORMANCE_MEASUREMENT
       
  1193       PERF_EVENT_START_L1( EPerfEventSwitchToStillMode );
       
  1194       iController.SetPerformanceState( EPerfWaitingForStillMode );
       
  1195       #endif    
       
  1196       
       
  1197       if ( iMode == ECamControllerVideo )
       
  1198         {
       
  1199         ZoomPane()->ResetZoomTo1x();    
       
  1200         }
       
  1201 
       
  1202       // Hide the active palette before switching so that 
       
  1203       // it is not visible until the preview is visible.
       
  1204 
       
  1205       SetActivePaletteVisibility( EFalse );
       
  1206       if( iController.UiConfigManagerPtr() && 
       
  1207           iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() && 
       
  1208           iVideoCaptureView->Container() )
       
  1209           {
       
  1210           PRINT( _L("Camera <> CCamAppUi::HandleCommandL calling Draw") ); 
       
  1211           iVideoCaptureView->Container()->DrawNow();
       
  1212           } 
       
  1213       // Switch to still pre capture view
       
  1214       iTargetViewState = ECamViewStatePreCapture;   	
       
  1215       // if coming from video mode then set single capture mode
       
  1216       // otherwise stay with the current capture mode
       
  1217       if ( iMode == ECamControllerVideo )
       
  1218         {
       
  1219         iTargetMode = ECamControllerImage;
       
  1220         }
       
  1221       TrySwitchViewL();
       
  1222       
       
  1223 
       
  1224       }
       
  1225       break;
       
  1226     case EEikCmdExit: // fallthrough
       
  1227     case EAknSoftkeyExit:
       
  1228       {
       
  1229       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP3_CCAMAPPUI_HANDLECOMMANDL, "e_ExternalExit 1" );
       
  1230       PRINT( _L("Camera CCamAppUi external exit call") );
       
  1231       if ( iEikonEnv->StartedAsServerApp() )
       
  1232         {
       
  1233         if ( iEmbeddedObserver )
       
  1234             {
       
  1235             iEmbeddedObserver->AbortL();
       
  1236             }
       
  1237         CloseAppL(); 
       
  1238         }
       
  1239       else
       
  1240 /*#ifndef __WINS__
       
  1241           {
       
  1242           if( iSendFileInCall )
       
  1243               {
       
  1244               // bring phone app to fore  ground
       
  1245               BringPhoneAppToForeGroundL();
       
  1246               }
       
  1247           else
       
  1248               {
       
  1249               // hide task icon immediately so it doesn't show during
       
  1250               // closing which might take a while
       
  1251               HideTaskL( ETrue );
       
  1252               CloseAppL();  	
       
  1253               }
       
  1254           }
       
  1255 #else*/
       
  1256           {
       
  1257           HideTaskL( ETrue );
       
  1258           CloseAppL();
       
  1259           }
       
  1260 //#endif
       
  1261         OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP5_CCAMAPPUI_HANDLECOMMANDL, "e_ExternalExit 0" );
       
  1262       }
       
  1263       break;
       
  1264     // -----------------------------------------------------
       
  1265     case ECamCmdInternalExit:
       
  1266       {
       
  1267       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_HANDLECOMMANDL, "e_ECamCmdInternalExit 1" );
       
  1268       PRINT( _L("Camera <> CCamAppUi::HandleCommandL case ECamCmdInternalExit") );            
       
  1269     #ifdef CAMERAAPP_PERF_LOG_MEMORY 
       
  1270       // Manually save the current memory log data. This is needed
       
  1271       // in case the application just goes to background, in which
       
  1272       // case the log data is not saved automatically.
       
  1273       CCamPerformanceLogger::SaveAndReset();
       
  1274     #endif  
       
  1275               
       
  1276     #ifdef CAMERAAPP_PERF_LOG_TRACES 
       
  1277       // Shutdown end event cannot be logged to memory logger
       
  1278       // So also log start event only to traces
       
  1279       if( !iController.AlwaysOnSupported() )
       
  1280         {
       
  1281         PERF_EVENT_START_TRACE( EPerfEventApplicationShutdown );
       
  1282         }
       
  1283     #endif  
       
  1284       PRINT( _L("Camera CCamAppUi::ECamCmdInternalExit") );
       
  1285       InternalExitL();
       
  1286       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_HANDLECOMMANDL, "e_ECamCmdInternalExit 0" );
       
  1287       }
       
  1288       break;  
       
  1289     // -----------------------------------------------------
       
  1290     case ECamCmdSlideClosedExit:
       
  1291       {
       
  1292       // The controller tells the AppUi that the app needs to 
       
  1293       // do an internal exit because the slider has closed.
       
  1294       // However the view needs to do some processing of this command
       
  1295       // e.g. to ensure that the application leaves standby mode.
       
  1296       // Pass the cammand on to the view. It will come back to
       
  1297       // the AppUi as ECamCmdInternalExit
       
  1298       OstTrace0( TRACE_PERFORMANCE_DETAIL, DUP2_CCAMAPPUI_HANDLECOMMANDL, "e_ECamCmdSlideClosedExit 1" );
       
  1299       
       
  1300       iLensCoverExit = ETrue;
       
  1301       PRINT( _L("Camera CCamAppUi::ECamCmdSlideClosedExit") );
       
  1302       if ( iView )
       
  1303         {
       
  1304         PRINT( _L("Camera CCamAppUi passing ECamCmdSlideClosedExit to iView") );
       
  1305         iView->HandleCommandL( ECamCmdInternalExit );
       
  1306         }
       
  1307       else
       
  1308         {
       
  1309         PRINT( _L("Camera CCamAppUi handlingECamCmdSlideClosedExit") );
       
  1310         HandleCommandL( ECamCmdInternalExit );
       
  1311         }
       
  1312       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP4_CCAMAPPUI_HANDLECOMMANDL, "e_ECamCmdSlideClosedExit 0" );
       
  1313       }
       
  1314       break;               
       
  1315     // -----------------------------------------------------
       
  1316     case EAknSoftkeyBack:
       
  1317       {
       
  1318       PRINT( _L("Camera <> CCamAppUi::HandleCommandL case EAknSoftkeyBack") );            
       
  1319       // If in burst mode
       
  1320       if ( iImageMode == ECamImageCaptureBurst )
       
  1321         {
       
  1322         // If in burst post-capture view, "back" is to the thumbnail grid
       
  1323         if ( iViewState == ECamViewStatePostCapture )
       
  1324           {
       
  1325           iTargetViewState = ECamViewStateBurstThumbnail ;
       
  1326           }
       
  1327         else // From any other burst view... 
       
  1328           {                             
       
  1329           iTargetViewState = ECamViewStatePreCapture;               
       
  1330           }
       
  1331         }
       
  1332         // Switch to pre capture view
       
  1333       else
       
  1334         {
       
  1335         iTargetViewState = ECamViewStatePreCapture;   	
       
  1336         }
       
  1337       TrySwitchViewL();
       
  1338       }
       
  1339       break;
       
  1340     // -----------------------------------------------------
       
  1341     case ECamCmdDelete:
       
  1342       {
       
  1343       // Request that the view displays the delete confirmation note
       
  1344 	  if(!iController.IsProcessingCapture())
       
  1345 		{
       
  1346 		DisplayDeleteNoteL();
       
  1347 		}
       
  1348 	  else
       
  1349 		{
       
  1350 		//Do Nothing
       
  1351 		}
       
  1352       }
       
  1353       break;
       
  1354     // -----------------------------------------------------
       
  1355     case ECamCmdNewVideo:
       
  1356       {
       
  1357       // check if currently preparing return
       
  1358       if ( iController.CaptureModeTransitionInProgress() )
       
  1359         {
       
  1360         return;
       
  1361         }
       
  1362       #ifdef CAMERAAPP_PERFORMANCE_MEASUREMENT
       
  1363       PERF_EVENT_START_L1( EPerfEventSwitchToVideoMode );
       
  1364       iController.SetPerformanceState( EPerfWaitingForVideoMode );
       
  1365       #endif
       
  1366       
       
  1367       if ( iMode == ECamControllerImage )
       
  1368         {
       
  1369         ZoomPane()->ResetZoomTo1x();    
       
  1370         }
       
  1371       
       
  1372       // Hide the active palette before any attempt to switch off burst mode
       
  1373       // otherwise the view switch to video fails when we call GetFocusWindowGroup to
       
  1374       // see which application has the foreground. Use SetSuppressUIRiseOnViewfinderStart
       
  1375       // otherwise the AP is raised automatically when the viewfinder starts.
       
  1376             
       
  1377       SetActivePaletteVisibility( EFalse );
       
  1378       SetSuppressUIRiseOnViewfinderStart( ETrue );                
       
  1379       // Switch burst mode off before changing to video
       
  1380       if ( IsBurstEnabled() )
       
  1381         {
       
  1382         SwitchStillCaptureModeL( ECamImageCaptureSingle, EFalse );
       
  1383         PRINT( _L("Camera => CCamAppUi::HandleCommandL ECamCmdNewVideo completed switch to single"));
       
  1384         }
       
  1385 
       
  1386       // Switch to video pre capture view
       
  1387       iTargetViewState = ECamViewStatePreCapture;
       
  1388       iTargetMode = ECamControllerVideo;
       
  1389       SetSuppressUIRiseOnViewfinderStart( EFalse );
       
  1390       PRINT( _L("Camera => CCamAppUi::HandleCommandL Try switch to video mode"));
       
  1391       TrySwitchViewL();
       
  1392       }
       
  1393       break;
       
  1394     // -----------------------------------------------------
       
  1395     case ECamCmdSelfTimer1: // 10-sec self-timer
       
  1396       {
       
  1397       SelfTimerEnableL( ECamSelfTimerMode1 );
       
  1398       }             
       
  1399       break;
       
  1400     // -----------------------------------------------------
       
  1401     case ECamCmdSelfTimer2: // 2-sec self-timer
       
  1402       {
       
  1403       SelfTimerEnableL( ECamSelfTimerMode2 );
       
  1404       }             
       
  1405       break;
       
  1406     // -----------------------------------------------------
       
  1407     case ECamCmdSelfTimer3: // (not supported)
       
  1408       {
       
  1409       SelfTimerEnableL( ECamSelfTimerMode3 );
       
  1410       }             
       
  1411       break;
       
  1412     // -----------------------------------------------------
       
  1413     case ECamCmdSelfTimerActivate:
       
  1414       {
       
  1415         // Self timed capture happens either from shutter press or
       
  1416         // self timer activate event from softkey press. Shutter
       
  1417         // press case is handled in CCamStillPreCaptureContainer.
       
  1418         if( iController.UiConfigManagerPtr()->IsXenonFlashSupported() && 
       
  1419             !iController.CheckFlash() )
       
  1420             {
       
  1421             // Flash is not ready for taking a picture
       
  1422             return;            
       
  1423             }        
       
  1424 
       
  1425       // In touch UI we will get two ECamCmdSelfTimerActivate commands
       
  1426       // immediately then the user touches the left softkey to activate
       
  1427       // self-timer. We need to ignore the second one to enable the counter
       
  1428       // to count down properly.
       
  1429       
       
  1430       // only start countdown if there is space to save image
       
  1431       if ( CheckMemoryL() )
       
  1432         {
       
  1433         if ( iMode != ECamControllerVideo )
       
  1434           {
       
  1435           InitCaptureCountL();
       
  1436           }
       
  1437         // Start capture operation NOW
       
  1438         iSelfTimer->StartSelfTimer();            
       
  1439           
       
  1440         if ( iController.IsTouchScreenSupported() )
       
  1441           {
       
  1442           CAknToolbar* toolbar = CurrentFixedToolbar();
       
  1443           if (toolbar)
       
  1444             {
       
  1445             toolbar->SetToolbarVisibility( EFalse );
       
  1446             }
       
  1447           }
       
  1448             
       
  1449         iPreventActivePaletteDisplay = ETrue;
       
  1450         SetActivePaletteVisibility( EFalse );           
       
  1451            
       
  1452         // Update CBA
       
  1453         UpdateCba();
       
  1454         }
       
  1455       }
       
  1456       break;
       
  1457     // -----------------------------------------------------
       
  1458     case ECamCmdSelfTimerCancel:
       
  1459       {
       
  1460       // Called when the user clicks "Cancel" to leave self-timer mode
       
  1461       SelfTimerEnableL( ECamSelfTimerDisabled );
       
  1462       }
       
  1463       break;
       
  1464     // -----------------------------------------------------
       
  1465     case ECamCmdSettings:
       
  1466       {
       
  1467       // Turn off the courtesy timer if its active so that the softkeys
       
  1468       // will remain active
       
  1469       if( iCourtesyTimer )
       
  1470         {
       
  1471         iCourtesyTimer->Cancel();
       
  1472         }
       
  1473 
       
  1474       iReturnedFromPlugin = EFalse;
       
  1475       iSettingsPluginLaunched = ETrue;
       
  1476       SetActivePaletteVisibility( EFalse );
       
  1477       CCamViewBase* precapView = NULL;
       
  1478       if ( iView == iStillCaptureView ||
       
  1479           iView == iVideoCaptureView )
       
  1480         {
       
  1481         precapView = static_cast<CCamViewBase*>( iView );
       
  1482         __ASSERT_DEBUG(precapView, CamPanic(ECamPanicNullPointer));
       
  1483 		precapView->BlankSoftkeysL();
       
  1484         }
       
  1485       iTargetViewState = ECamViewStateSettings;
       
  1486       if ( iController.IsTouchScreenSupported() )
       
  1487          {
       
  1488           CAknToolbar* toolbar = CurrentFixedToolbar();
       
  1489           if ( toolbar )
       
  1490               {
       
  1491               toolbar->SetToolbarVisibility( EFalse );
       
  1492               }
       
  1493           }
       
  1494       TrySwitchViewL();
       
  1495       }
       
  1496       break;
       
  1497     // -----------------------------------------------------
       
  1498     case ECamCmdSelect:
       
  1499       {
       
  1500       PRINT( _L("Camera => CCamAppUi::HandleCommandL ECamCmdSelect"));
       
  1501       if ( iEikonEnv->StartedAsServerApp() )
       
  1502         {
       
  1503         const TDesC& name( iController.CurrentFullFileName() );
       
  1504         
       
  1505         PRINT1( _L("Camera => CCamAppUi::HandleCommandL ECamCmdSelect %S"), &name )
       
  1506         iEmbeddedObserver->FileCompleteL( name );
       
  1507         iController.EnterShutdownMode( ETrue );
       
  1508         }
       
  1509 /*#ifndef __WINS__
       
  1510       else if ( iSendFileInCall )
       
  1511         {
       
  1512         PRINT( _L("CCamAppUi::HandleCommandL SendMedia file") )
       
  1513         // handle in-call send interaction
       
  1514         
       
  1515         // Sending of captured media file and to return to call view after sending        			
       
  1516         BringPhoneAppToForeGroundL(); 
       
  1517         DoInCallSendL();			  
       
  1518         HideTaskL( ETrue ); // otherwise camera would show in "Active Applications"   		
       
  1519         iPretendExit = ETrue; // we are basicly in a "pretended exit" state
       
  1520         //BringPhoneAppToForeGroundL();
       
  1521         }
       
  1522 #endif*/               
       
  1523       else
       
  1524         {
       
  1525         // ACS What do we need to do here? Call internal exit?
       
  1526         // this will exit when any current process completes
       
  1527         iController.EnterShutdownMode( EFalse );
       
  1528         }
       
  1529       }
       
  1530       break;
       
  1531     // -----------------------------------------------------
       
  1532     case EAknSoftkeyEmpty: // Must handle this key, but do nothing
       
  1533       break;
       
  1534     // -----------------------------------------------------
       
  1535     case ECamCmdPhotos:
       
  1536       { 
       
  1537       TUid msgUidLastModified(TUid::Uid(KGlxActivationCmdShowLastModified));
       
  1538       TUid msgUidCameraAlbum(TUid::Uid(KGlxActivationCameraAlbum));
       
  1539       TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
       
  1540       TApaTask apaTask = apaTaskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid) );
       
  1541         
       
  1542       TBuf8<100> buffer;
       
  1543       RDesWriteStream stream( buffer );
       
  1544       CleanupClosePushL( stream );
       
  1545       stream.Open( buffer );
       
  1546       
       
  1547 
       
  1548       if ( ECamViewStatePreCapture == iViewState )
       
  1549           {
       
  1550           stream << msgUidCameraAlbum;          
       
  1551           }
       
  1552       else 
       
  1553           {
       
  1554           stream << msgUidLastModified;
       
  1555           }
       
  1556       stream.CommitL();
       
  1557 
       
  1558       //Hide fixed toolbar before calling to start photos.
       
  1559       if ( iController.IsTouchScreenSupported() && 
       
  1560            IsSecondCameraEnabled() && 
       
  1561            iViewState == ECamViewStatePreCapture )
       
  1562           {         
       
  1563           CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  1564           if ( fixedToolbar )
       
  1565               {
       
  1566               fixedToolbar->SetToolbarVisibility( EFalse );
       
  1567               }
       
  1568           //Bitmap mode's VF consumes much of CPU in second camera, stop VF in advance to accelerate switching to photos.
       
  1569           iController.StopViewFinder(); 
       
  1570           }
       
  1571 
       
  1572       if ( apaTask.Exists() )
       
  1573           {
       
  1574           // sending APA task message
       
  1575           apaTask.SendMessage( TUid::Uid( KGlxActivationCmdShowLastModified ), 
       
  1576                                           buffer );
       
  1577           }
       
  1578       else // Photos Application is not running
       
  1579           {
       
  1580           StartAppCmdLineL( buffer );
       
  1581           }
       
  1582       CleanupStack::PopAndDestroy( &stream );
       
  1583       }
       
  1584       break;
       
  1585       // -----------------------------------------------------
       
  1586       // This should only be available when time lapse is not supported    
       
  1587       // so the current mode should be still or multi
       
  1588     case ECamCmdToggleMulti:
       
  1589       {
       
  1590       if ( iImageMode == ECamImageCaptureSingle )
       
  1591         {
       
  1592         TRAPD( ignore, SwitchStillCaptureModeL( ECamImageCaptureBurst, ETrue ) );
       
  1593         if ( ignore )
       
  1594             {
       
  1595             // do nothing
       
  1596             }
       
  1597         }
       
  1598       else if ( iImageMode == ECamImageCaptureBurst )   
       
  1599         {
       
  1600         SwitchStillCaptureModeL( ECamImageCaptureSingle, ETrue );
       
  1601         }
       
  1602       else
       
  1603         {
       
  1604         // Lint
       
  1605         }
       
  1606       
       
  1607       // Update timelapse interval
       
  1608       iController.SetTimeLapseInterval( 0 );
       
  1609       
       
  1610       // stop and start the viewfinder in order to update the settings   
       
  1611       iController.ExitViewfinderMode( ECamControllerImage );
       
  1612       iController.EnterViewfinderMode( ECamControllerImage );
       
  1613       
       
  1614       }
       
  1615       break;
       
  1616     // -----------------------------------------------------
       
  1617     // Toggle facetracking setting
       
  1618     case ECamCmdToggleFacetracking:
       
  1619       {
       
  1620       if ( iController.UiConfigManagerPtr()->IsFaceTrackingSupported() )
       
  1621         {
       
  1622         if ( iController.IntegerSettingValue( ECamSettingItemFaceTracking ) == ECamSettOn )
       
  1623             {
       
  1624             iController.SetIntegerSettingValueL( 
       
  1625                                          ECamSettingItemFaceTracking,
       
  1626                                          ECamSettOff );
       
  1627             }
       
  1628         else 
       
  1629             {
       
  1630             iController.SetIntegerSettingValueL( 
       
  1631                                          ECamSettingItemFaceTracking,
       
  1632                                          ECamSettOn );
       
  1633             }
       
  1634         iController.TryAFRequest( ECamRequestCancelAutofocus );
       
  1635         }
       
  1636       }
       
  1637       break;
       
  1638     // -----------------------------------------------------
       
  1639     // Switch to single capture
       
  1640     case ECamCmdSingleCapture:
       
  1641       {
       
  1642       SwitchStillCaptureModeL( ECamImageCaptureSingle, ETrue );
       
  1643       }
       
  1644       break;
       
  1645     // -----------------------------------------------------
       
  1646     // Activate burst mode
       
  1647     case ECamCmdSequence:       
       
  1648       {
       
  1649       SwitchStillCaptureModeL( ECamImageCaptureBurst, ETrue );
       
  1650       }
       
  1651       break;
       
  1652     // -----------------------------------------------------
       
  1653     // Activate time lapse mode    
       
  1654     case ECamCmdTimeLapse:
       
  1655       {
       
  1656       SwitchStillCaptureModeL( ECamImageCaptureTimeLapse, ETrue );
       
  1657       }
       
  1658       break;
       
  1659     // -----------------------------------------------------
       
  1660     case ECamCmdOpenPhoto:
       
  1661       {
       
  1662       if(iViewState == ECamViewStateBurstThumbnail )
       
  1663         {
       
  1664         iTargetViewState = ECamViewStatePostCapture;
       
  1665         TrySwitchViewL();
       
  1666         }
       
  1667       }
       
  1668       break;
       
  1669     // -----------------------------------------------------
       
  1670     case ECamCmdUserScene:
       
  1671       {
       
  1672       iTargetViewState = ECamViewStateUserSceneSetup;
       
  1673       TrySwitchViewL();
       
  1674       }
       
  1675       break;
       
  1676     // -----------------------------------------------------
       
  1677     case ECamCmdPlay:   
       
  1678       {
       
  1679       TDataType dataType;
       
  1680       SetEmbedding( ETrue );
       
  1681       iDocHandler->OpenFileEmbeddedL( iController.CurrentFullFileName(),
       
  1682                                       dataType );
       
  1683       }
       
  1684       break;
       
  1685      // -----------------------------------------------------
       
  1686      case ECamCmdSwitchCamera:
       
  1687          {
       
  1688          PRINT( _L("Camera => CCamAppUi::HandleCommandL ECamCmdSwitchCamera" ))
       
  1689          //If modechange sequence going on ignore switching...
       
  1690          if( iController.CaptureModeTransitionInProgress() ||
       
  1691              iController.CaptureState() != ECamCaptureOff || 
       
  1692              iController.IsSavingInProgress() )
       
  1693              {
       
  1694              PRINT( _L("Camera <= CCamAppUi::HandleCommandL STOP ECamCmdSwitchCamera" ))
       
  1695              iController.SetCameraSwitchRequired( ESwitchDone );
       
  1696              break;
       
  1697              } 
       
  1698          
       
  1699          // Hide fixed toolbar and softkeys to prevent blinking
       
  1700          if ( iController.IsTouchScreenSupported() )
       
  1701              {         
       
  1702              CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  1703              if ( fixedToolbar )
       
  1704                  {
       
  1705                  fixedToolbar->SetToolbarVisibility( EFalse );
       
  1706                  }
       
  1707              }
       
  1708          CCamViewBase* precapView = static_cast<CCamViewBase*>( iView );
       
  1709 		 __ASSERT_DEBUG( precapView, CamPanic( ECamPanicNullPointer ));
       
  1710          if ( precapView )
       
  1711              {
       
  1712              precapView->ViewCba()->MakeVisible( EFalse );
       
  1713              }
       
  1714            
       
  1715          PRINT( _L("Camera <> CCamAppUi::HandleCommandL continue ECamCmdSwitchCamera" ))
       
  1716 
       
  1717          if ( ActiveCamera() == ECamActiveCameraPrimary && IsBurstEnabled() )
       
  1718              {
       
  1719              SwitchStillCaptureModeL( ECamImageCaptureSingle, EFalse );
       
  1720              }
       
  1721 
       
  1722          TInt primaryOrientation   = EAppUiOrientationUnspecified;
       
  1723          TInt secondaryOrientation = EAppUiOrientationUnspecified;
       
  1724          TCamPsiKey orientation = IsQwerty2ndCamera( ETrue )?     
       
  1725                                   ECamPsiPrimaryCameraOrientation:
       
  1726                                   ECamPsiSecondaryCameraOrientation;
       
  1727          if ( !CamUtility::GetPsiInt( ECamPsiPrimaryCameraOrientation, 
       
  1728                                       primaryOrientation ) &&
       
  1729               !CamUtility::GetPsiInt( orientation, 
       
  1730                                       secondaryOrientation ) )  
       
  1731              {
       
  1732              if ( primaryOrientation != secondaryOrientation || IsQwerty2ndCamera() )
       
  1733                  {
       
  1734                  if( ( !IsSecondCameraEnabled() || 
       
  1735                        iController.CameraSwitchQueued() == ESwitchSecondaryOrientation ) &&
       
  1736                      !IsQwerty2ndCamera() )  
       
  1737                      {
       
  1738                      PRINT( _L("Camera => CCamAppUi::HandleCommandL ECamCmdSwitchCamera 2ndary portrait" ))
       
  1739                      iCamOrientation = ECamOrientationPortrait;
       
  1740                      SetOrientationL( static_cast<TAppUiOrientation>( secondaryOrientation ) );
       
  1741 
       
  1742                      if ( iController.IsTouchScreenSupported() )
       
  1743                          {
       
  1744                          iStillCaptureView->CreateAndSetToolbarL( R_CAM_STILL_PRECAPTURE_TOOLBAR_PORTRAIT );
       
  1745                          iVideoCaptureView->CreateAndSetToolbarL( R_CAM_VIDEO_PRECAPTURE_TOOLBAR_PORTRAIT );
       
  1746                          }
       
  1747 
       
  1748                      StatusPane()->MakeVisible( ETrue );
       
  1749                      }
       
  1750                  else
       
  1751                      {
       
  1752                      PRINT( _L("Camera => CCamAppUi::HandleCommandL ECamCmdSwitchCamera 1ary or 2nd landscape" ))
       
  1753                      iCamOrientation = (iSoftkeyPosition == ECamHandLeft)
       
  1754                      ? ECamOrientationCamcorderLeft
       
  1755                          : ECamOrientationCamcorder;
       
  1756 
       
  1757                      SetOrientationL( 
       
  1758                         static_cast<TAppUiOrientation>( primaryOrientation ) );
       
  1759 
       
  1760                      if ( iController.IsTouchScreenSupported() )
       
  1761                          {
       
  1762                          if ( ( !IsSecondCameraEnabled() || iController.CameraSwitchQueued() == ESwitchSecondaryOrientation ) &&
       
  1763                                IsQwerty2ndCamera() )   
       
  1764                             {
       
  1765                             iStillCaptureView->CreateAndSetToolbarL( 
       
  1766                                     R_CAM_STILL_PRECAPTURE_TOOLBAR_LANDSCAPE );
       
  1767                             iVideoCaptureView->CreateAndSetToolbarL( 
       
  1768                                     R_CAM_VIDEO_PRECAPTURE_TOOLBAR_LANDSCAPE );
       
  1769                             }
       
  1770                          else
       
  1771                             { 
       
  1772                             iStillCaptureView->CreateAndSetToolbarL( 
       
  1773                                     R_CAM_STILL_PRECAPTURE_TOOLBAR );
       
  1774                             if(iController.UiConfigManagerPtr()->IsXenonFlashSupported())
       
  1775                                 {
       
  1776                                 iVideoCaptureView->CreateAndSetToolbarL(R_CAM_VIDEO_PRECAPTURE_TOOLBAR);
       
  1777                                 iVideoCaptureView->UpdateToolbarIconsL();
       
  1778                                 }
       
  1779                             else
       
  1780                                 {
       
  1781                                 iVideoCaptureView->CreateAndSetToolbarL(R_CAM_VIDEO_PRECAPTURE_TOOLBAR_VIDEOLIGHT);
       
  1782                                 }
       
  1783                             }
       
  1784                          }
       
  1785 
       
  1786                      StatusPane()->MakeVisible( EFalse );
       
  1787                      }
       
  1788                  UpdateNaviModelsL();
       
  1789 
       
  1790                  //Reset zoom when changing cameras
       
  1791                  ZoomPane()->ResetZoomTo1x(); 
       
  1792 
       
  1793                  TInt rl( 0 );
       
  1794                  for ( rl = 0; rl < iResourceLoaders.Count(); rl++ )
       
  1795                      {
       
  1796                      iResourceLoaders[rl]->ReloadResourceDataL();
       
  1797                      }
       
  1798 
       
  1799                  iCamSidePane->UpdateLayout();          
       
  1800                  iTargetViewState = ECamViewStatePreCapture;
       
  1801                  delete iScreenClearer;
       
  1802                  iScreenClearer = NULL;
       
  1803                  iScreenClearer = CAknLocalScreenClearer::NewL( 
       
  1804                               IsSecondCameraEnabled() || IsQwerty2ndCamera() );
       
  1805                  TrySwitchViewL( ETrue );
       
  1806                  iController.SwitchCameraL();       
       
  1807                  }
       
  1808              }
       
  1809          }                
       
  1810          break;
       
  1811     // -----------------------------------------------------
       
  1812     case EAknCmdHelp:
       
  1813       {
       
  1814       LaunchHelpL();
       
  1815       }
       
  1816       break;
       
  1817     // -----------------------------------------------------
       
  1818     case ECamCmdRedrawScreen:
       
  1819       {
       
  1820       if( !iProcessingScreenRedraw && iView )
       
  1821         {
       
  1822         iProcessingScreenRedraw = ETrue;
       
  1823         iView->HandleCommandL(ECamCmdRedrawScreen);
       
  1824         iProcessingScreenRedraw = EFalse;
       
  1825         }
       
  1826       }
       
  1827       break;
       
  1828     // -----------------------------------------------------
       
  1829     case ECamCmdShootSetup: // fall through
       
  1830     case ECamCmdFlash:      // fall through
       
  1831     case ECamCmdAddAudio:   // fall through
       
  1832     case ECamCmdEdit:       // fall through
       
  1833     case ECamCmdPrint:      // fall through
       
  1834     case ECamCmdSendToCallerMultimedia: // fall through
       
  1835     case ECamCmdRenameImage:            // fall through
       
  1836     case ECamCmdRenameVideo:            // fall through        
       
  1837       {
       
  1838       User::Leave( KErrNotSupported );
       
  1839       }
       
  1840       break;
       
  1841 
       
  1842     // -----------------------------------------------------
       
  1843     case ECamCmdViewfinderGrid:
       
  1844       {
       
  1845       SelectViewFinderGridSettingL();
       
  1846       break;     
       
  1847       }
       
  1848 
       
  1849     // -----------------------------------------------------
       
  1850     case EAknCmdTaskSwapper:
       
  1851     	/*
       
  1852     	* MSK: Active Applications
       
  1853     	* This command is actually handled by Avkon FW
       
  1854     	* Applications should not handle this
       
  1855     	*/
       
  1856     	break;
       
  1857     //-------------------------------------------------------
       
  1858     default:
       
  1859       {
       
  1860       PRINT( _L("Camera <> CCamAppUi::HandleCommandL does nothing") )
       
  1861       } 
       
  1862       break;
       
  1863     }
       
  1864     // -----------------------------------------------------
       
  1865     PRINT( _L("Camera <= CCamAppUi::HandleCommandL") )
       
  1866   } 
       
  1867 
       
  1868 // ===========================================================================
       
  1869 // From MCamCameraObserver
       
  1870 
       
  1871 // -----------------------------------------------------------------------------
       
  1872 // -----------------------------------------------------------------------------
       
  1873 //
       
  1874 
       
  1875 void
       
  1876 CCamAppUi::HandleCameraEventL( TInt              /*aStatus*/, 
       
  1877                                TCamCameraEventId  aEventId, 
       
  1878                                TAny*             /*aEventData //= NULL */
       
  1879                              )
       
  1880   {
       
  1881   switch( aEventId )
       
  1882     {        
       
  1883     // -----------------------------------------------------
       
  1884     case ECamCameraEventVfStart: // ECamEventViewFinderStarted
       
  1885       {
       
  1886       PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventVfStart" ) )
       
  1887       if( iScreenClearer )
       
  1888         {
       
  1889         delete iScreenClearer;
       
  1890         iScreenClearer = NULL;
       
  1891         }
       
  1892 #ifdef CAMERAAPP_DELAYED_POSTCAPTURE_CREATION
       
  1893         
       
  1894       // Construct postcapture views when idle  
       
  1895       // or latest when view switch is requested
       
  1896       StartPostCapIdleL();
       
  1897 #else               
       
  1898       TRAPD( err, ConstructPostCaptureViewsL() )
       
  1899       if ( KErrNone != err )
       
  1900         {
       
  1901         TRAP_IGNORE( HandleCameraErrorL( err ) );
       
  1902 
       
  1903         // if embedded need to notify embeddee
       
  1904         if ( iEikonEnv->StartedAsServerApp() )
       
  1905           {
       
  1906           iEmbeddedObserver->AbortL();
       
  1907           }
       
  1908         else
       
  1909           {
       
  1910           CloseAppL();  
       
  1911           }
       
  1912         }
       
  1913 #endif            
       
  1914       // Only show the Active Palette once viewfinding has started
       
  1915       iPreventActivePaletteDisplay = EFalse;     
       
  1916 
       
  1917       // For forced focus scenes, do one autofocus request once vf starts if needed
       
  1918       if( iController.UiConfigManagerPtr()->IsAutoFocusSupported() )
       
  1919         {
       
  1920         if( iController.CurrentSceneHasForcedFocus() ) 
       
  1921             {
       
  1922             PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL, TryAFRequest( ECamRequestCancelAutofocus )") );        
       
  1923             //Only autofocuscancel will set AFrange which is needed for forced focus cases
       
  1924             iController.TryAFRequest( ECamRequestCancelAutofocus );
       
  1925             }
       
  1926         else // For scenes with reticule cancel the autofocus, which sets the focus correctly
       
  1927             {
       
  1928             if ( iController.UiConfigManagerPtr()->IsAutofocusSetInHyperfocalAtStartup() )
       
  1929                 {
       
  1930                 PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL, TryAFRequest( ECamRequestCancelAutofocus )") );
       
  1931                 iController.TryAFRequest( ECamRequestCancelAutofocus );
       
  1932                 }
       
  1933             else if ( !iFirstVFStart )
       
  1934                 {
       
  1935                 iController.TryAFRequest( ECamRequestCancelAutofocus );
       
  1936                 }
       
  1937             }
       
  1938         }
       
  1939       iFirstVFStart = EFalse;
       
  1940       
       
  1941       break;              
       
  1942       }
       
  1943       // -----------------------------------------------------
       
  1944       case ECamCameraEventVideoAsyncStop: // Audio and video streams are stopped
       
  1945         {
       
  1946         PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventVideoAsyncStop" ) )
       
  1947         // Stop View finder if not needed to left run
       
  1948         if ( iController.IntegerSettingValue( ECamSettingItemVideoShowCapturedVideo ) == ECamSettOn ) 
       
  1949           {
       
  1950           iController.StopViewFinderEcam();
       
  1951           }
       
  1952         break;              
       
  1953         }
       
  1954     // -----------------------------------------------------        
       
  1955     case ECamCameraEventPowerOnRequested:
       
  1956     case ECamCameraEventReserveRequested:
       
  1957       {
       
  1958       // event only send if UIOrientationOverride feature is supported,
       
  1959       // in that case UI construction is divided into two parts, call here 
       
  1960       // to complete the construction	if in first startup
       
  1961       if( iFirstBoot )
       
  1962           {	
       
  1963           PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventReserveRequested/ECamCameraEventPowerOnRequested" ) )	
       
  1964           if ( iWaitTimer->IsActive() )
       
  1965               {
       
  1966               PRINT( _L( "Camera <> timer already active" ) )
       
  1967               iWaitTimer->Cancel();
       
  1968               }
       
  1969           PRINT( _L( "Camera <> start the appui construct timer" ) )
       
  1970           iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );  
       
  1971           }
       
  1972       else
       
  1973           {
       
  1974           //load settings in case they were changed via GS	
       
  1975           iController.LoadStaticSettingsL( IsEmbedded() );
       
  1976           // and check the availability of the memory to be used
       
  1977           iController.CheckMemoryToUseL();
       
  1978           }    
       
  1979       break;  
       
  1980       }
       
  1981     default:
       
  1982       {
       
  1983       break;  
       
  1984       }  
       
  1985       
       
  1986     }    
       
  1987 
       
  1988   }
       
  1989 // ===========================================================================
       
  1990 
       
  1991 // -----------------------------------------------------------------------------
       
  1992 // CCamAppUi::HandleControllerEventL
       
  1993 // Handle controller events
       
  1994 // -----------------------------------------------------------------------------
       
  1995 //
       
  1996 void 
       
  1997 CCamAppUi::HandleControllerEventL( TCamControllerEvent aEvent, 
       
  1998                                    TInt                aError )
       
  1999   {
       
  2000   PRINT1( _L( "Camera => CCamAppUi::HandleControllerEventL() %d" ), aEvent ); 
       
  2001   switch ( aEvent )
       
  2002     {
       
  2003     // -----------------------------------------------------
       
  2004     case ECamEventExitRequested:
       
  2005       {
       
  2006       PRINT( _L( "Camera <> case ECamEventExitRequested" ) )
       
  2007       if ( SettingsLaunchedFromCamera() )
       
  2008         {
       
  2009         SettingsPluginExitedL( ECameraCompleteExit ); 
       
  2010         }
       
  2011       if ( iWaitTimer->IsActive() )
       
  2012         {
       
  2013         PRINT( _L( "Camera <> timer already active" ) )
       
  2014         iWaitTimer->Cancel();
       
  2015         }
       
  2016       PRINT( _L( "Camera <> start the exit timer" ) )
       
  2017       iWaitTimer->Start( 0, 0,  TCallBack( CallExit, this ) );  
       
  2018       break;
       
  2019       }
       
  2020     // -----------------------------------------------------
       
  2021     case ECamEventOperationStateChanged:
       
  2022       {
       
  2023       PRINT( _L("Camera <> case ECamEventOperationStateChanged") )
       
  2024 
       
  2025       switch ( iController.CurrentOperation() )
       
  2026         {
       
  2027         case ECamFocusing:
       
  2028           UpdateCba();
       
  2029           break;
       
  2030         case ECamCapturing:
       
  2031           iPreventActivePaletteDisplay = ETrue;
       
  2032           SetActivePaletteVisibility( EFalse );
       
  2033           //Image capture has started. If postcaptureview is enabled assume that postcapture
       
  2034           //is next view. Thus if camera goes to background and comes back to foreground don't
       
  2035           //start viewfinder because it is not needed in postcapture view. If image capture fails
       
  2036           //or is canceled enabling viewfinder is possible.
       
  2037           if ( iView && ( iStillCaptureView == iView || iVideoCaptureView == iView )
       
  2038                   && ShowPostCaptureView() )
       
  2039               {
       
  2040               SetAssumePostCaptureView( ETrue );
       
  2041               }
       
  2042           break;
       
  2043         case ECamStandby:
       
  2044           //DismissMemoryNote();
       
  2045           HandleStandbyEventL( aError );
       
  2046           break;         
       
  2047         case ECamNoOperation:
       
  2048             {
       
  2049             if( iPreventActivePaletteDisplay )
       
  2050                 {
       
  2051                 iPreventActivePaletteDisplay = EFalse;
       
  2052                 }            
       
  2053             }
       
  2054             break;
       
  2055         default:
       
  2056           break;
       
  2057         }
       
  2058       break;
       
  2059       }
       
  2060     // -----------------------------------------------------
       
  2061     case ECamEventRecordComplete:
       
  2062       {
       
  2063       PRINT( _L("Camera <> case ECamEventRecordComplete") )
       
  2064       // Dismiss the saving video clip wait dialog
       
  2065       if ( iWaitDialog )
       
  2066         {
       
  2067         iWaitDialog->ProcessFinishedL();
       
  2068         //iWaitDialog = NULL; //ProcessFinishedL() will make iWaitDialog NULL asynchronously
       
  2069         }
       
  2070 
       
  2071       // switch on active palette recording is complete
       
  2072       if( ECamOrientationCamcorder     == iCamOrientation 
       
  2073        || ECamOrientationCamcorderLeft == iCamOrientation 
       
  2074        || ECamOrientationPortrait      == iCamOrientation )
       
  2075         {
       
  2076         iPreventActivePaletteDisplay = EFalse;
       
  2077         if ( DrawPreCaptureCourtesyUI() )
       
  2078           {
       
  2079           SetActivePaletteVisibility( ETrue );
       
  2080           }
       
  2081         } 
       
  2082       if ( iController.InCallOrRinging() &&
       
  2083            iController.IntegerSettingValue( ECamSettingItemVideoShowCapturedVideo ) == ECamSettOn )
       
  2084         {
       
  2085         // when video recording is stopped by incoming call
       
  2086         // and post capture view is turned on, post capture timer
       
  2087         // should only start after some user interaction
       
  2088         iDelayVideoPostCaptureTimeout = ETrue;
       
  2089         }
       
  2090       }            //lint -fallthrough to switch to post capture view
       
  2091     // -----------------------------------------------------
       
  2092     case ECamEventSnapshotReady:
       
  2093       {
       
  2094       PRINT( _L("Camera <> case ECamEventSnapshotReady") )
       
  2095 
       
  2096       // If burst mode is active, do nothing until the whole burst completes
       
  2097       if ( IsBurstEnabled() )
       
  2098         {
       
  2099         // handle error if necessary
       
  2100         HandleCameraErrorL( aError );
       
  2101           
       
  2102         // Check if there was an error, and there were no successful
       
  2103         // captures.  In this case, we will be staying in pre-capture view
       
  2104         // so allow the active palette to be displayed again
       
  2105         if ( aError != KErrNone &&
       
  2106              iController.CurrentItemCount() == 0 )
       
  2107           {
       
  2108           iPreventActivePaletteDisplay = EFalse;
       
  2109           SetActivePaletteVisibility( ETrue );
       
  2110           }
       
  2111 
       
  2112         break;
       
  2113         }
       
  2114       // if the MMC has been removed while recording video to it, 
       
  2115       // don't go to post-capture view
       
  2116       else if ( iMode == ECamControllerVideo
       
  2117                 && iController.IntegerSettingValueUnfiltered( ECamSettingItemVideoMediaStorage ) 
       
  2118                     == ECamMediaStorageCard 
       
  2119                 && ( aError != KErrNone && aError != KErrDiskFull )
       
  2120                 && CamUtility::MemoryCardStatus() != ECamMemoryCardInserted )
       
  2121         {
       
  2122         iTargetViewState = ECamViewStatePreCapture;
       
  2123         }
       
  2124       // if USB was connected while MMC or mass storage was used as storage, 
       
  2125       // don't go to postcapture
       
  2126       else if ( CamUtility::IsUsbActive() && 
       
  2127                 ( iController.CurrentStorage() == ECamMediaStorageCard ||
       
  2128                 iController.CurrentStorage() == ECamMediaStorageMassStorage ) )
       
  2129         {
       
  2130         iTargetViewState = ECamViewStatePreCapture;
       
  2131         }
       
  2132       else if ( iController.IsCaptureStoppedForUsb() && 
       
  2133                 ( iController.CurrentStorage() == ECamMediaStorageCard ||
       
  2134                 iController.CurrentStorage() == ECamMediaStorageMassStorage ) )
       
  2135         {
       
  2136         PRINT( _L("Camera <> HandleControllerEventL ECamEventSnapshotReady: video stopped for usb" ) );
       
  2137         iTargetViewState = ECamViewStatePreCapture;
       
  2138         }
       
  2139       // If there was an error (we have no snap), we must stay in pre-capture view
       
  2140       else if ( aError )
       
  2141         {
       
  2142         iPreventActivePaletteDisplay = EFalse;
       
  2143         SetActivePaletteVisibility( ETrue );
       
  2144         iController.SetCaptureKeyPressedWhileImageSaving(EFalse);
       
  2145         // To be able to continue viewfinding
       
  2146         iController.FreezeViewFinder( EFalse );
       
  2147 
       
  2148         iTargetViewState = ECamViewStatePreCapture;
       
  2149         }               
       
  2150       // If the user has the show captured image setting turned on.
       
  2151       // switch to post capture view (Except in burst mode)            
       
  2152       else if ( ShowPostCaptureView() )
       
  2153           {
       
  2154           if( iController.CaptureKeyPressedWhileImageSaving() )
       
  2155               {
       
  2156               PRINT( _L("Camera <> HandleControllerEventL ECamEventSnapshotReady - Capture key pressed while saving ") )
       
  2157               iController.SetCaptureKeyPressedWhileImageSaving(EFalse);
       
  2158               iTargetViewState = ECamViewStatePreCapture;
       
  2159               SetSuppressUIRiseOnViewfinderStart( ETrue );
       
  2160               // To be able to continue viewfinding
       
  2161               iController.FreezeViewFinder( EFalse );
       
  2162               }
       
  2163           else
       
  2164               {
       
  2165               if ( !CamUtility::IsBatteryPowerEmpty() )
       
  2166                 { 
       
  2167                 if ( iLensCoverExit )
       
  2168                   {
       
  2169                   PRINT (_L ("Camera <> set target to precapture if Battery not Empty") );
       
  2170                   iTargetViewState = ECamViewStatePreCapture;
       
  2171                   }
       
  2172                 else
       
  2173                   {
       
  2174                   PRINT (_L ("Camera <> set target to postcapture if Battery not Empty") );
       
  2175                   iTargetViewState = ECamViewStatePostCapture;
       
  2176 				  
       
  2177                   //We need to blank the precapture view CBA here to prevent
       
  2178                   //blinking when changing back to precapture from postcapture
       
  2179                   UpdateCba();
       
  2180                   }
       
  2181                 }
       
  2182               }
       
  2183           }
       
  2184       
       
  2185       // Always switch to post capture view if self timer is enabled
       
  2186       else if ( iInSelfTimerMode != ECamSelfTimerDisabled )
       
  2187           {
       
  2188           iTargetViewState = ECamViewStatePostCapture;
       
  2189           // ensure that the view doesn't switch to precapture view when
       
  2190           // ECamEventCaptureComplete is received
       
  2191           iSelfTimedCapture = ETrue;
       
  2192           }
       
  2193       // Otherwise, 
       
  2194       // if not showing captured images go straight to pre capture view 
       
  2195       // (Except in burst mode)
       
  2196       else               
       
  2197           {
       
  2198           iTargetViewState = ECamViewStatePreCapture;
       
  2199           SetSuppressUIRiseOnViewfinderStart( ETrue );
       
  2200           }
       
  2201           
       
  2202       // The app is not going to try to switch to post capture view at all
       
  2203       // so the array needs to be released now.
       
  2204       if ( iTargetViewState == ECamViewStatePreCapture )
       
  2205           {
       
  2206           iController.ReleaseArray();
       
  2207           }
       
  2208           
       
  2209       // If no view switch is needed make sure the cba is not disabled
       
  2210       // and the self timer is switched off
       
  2211       if ( ViewSwitchRequired() != ECamViewSwitch )
       
  2212           {                
       
  2213           if ( iInSelfTimerMode != ECamSelfTimerDisabled )
       
  2214               {
       
  2215               SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2216               }
       
  2217           UpdateCba();
       
  2218           }
       
  2219       TrySwitchViewL();
       
  2220 
       
  2221       break;
       
  2222       }
       
  2223     // -----------------------------------------------------
       
  2224     case ECamEventCaptureComplete:
       
  2225       {
       
  2226       PRINT( _L("Camera <> case ECamEventCaptureComplete") )
       
  2227       // check if exit is required
       
  2228       if ( iController.CheckExitStatus() )
       
  2229         {
       
  2230         PRINT( _L("Camera <> calling internal exit after checking exit status") )
       
  2231         // The exit event is replacing the view switch, 
       
  2232         // so  release the array now
       
  2233         iController.ReleaseArray();
       
  2234         InternalExitL();
       
  2235         return;
       
  2236         }
       
  2237       if( ECamControllerImage == iMode )
       
  2238         {
       
  2239         switch( iImageMode )
       
  2240           {
       
  2241           // -----------------------------
       
  2242           // If burst mode is active, 
       
  2243           // only switch view when the whole burst completes
       
  2244           case ECamImageCaptureBurst:
       
  2245             {
       
  2246             // If there are images to show (i.e. user has not cancelled), 
       
  2247             // switch to thumbnail view. "Show captured images" setting has no
       
  2248             // effect in burst mode
       
  2249             
       
  2250             if ( iController.CurrentItemCount() != 0 && !iController.IsCaptureStoppedForUsb() )
       
  2251               {
       
  2252               iTargetViewState = ECamViewStateBurstThumbnail;
       
  2253               
       
  2254               // Normally iPreventActivePaletteDisplay is set to EFalse when
       
  2255               // postcture AP is shown, but in burst case that doesn't
       
  2256               // necessarily happen so do this here.
       
  2257               iPreventActivePaletteDisplay = EFalse;
       
  2258               }
       
  2259             // Otherwise, no images to show. Go straight to pre capture view. 
       
  2260             else               
       
  2261               {
       
  2262               iTargetViewState = ECamViewStatePreCapture;
       
  2263               // The app is not going to try to switch to post capture view at 
       
  2264               // all. So the array needs to be released now.
       
  2265               iController.ReleaseArray();
       
  2266               iController.StopViewFinder(); 
       
  2267               iController.StartViewFinder();
       
  2268               }
       
  2269             // If no view switch is needed make sure the cba is not disabled
       
  2270             // and the self timer is switched off
       
  2271             if ( ViewSwitchRequired() != ECamViewSwitch )
       
  2272               {
       
  2273               if ( iInSelfTimerMode != ECamSelfTimerDisabled )
       
  2274                 {
       
  2275                 SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2276                 }
       
  2277                 UpdateCba();
       
  2278               }
       
  2279     
       
  2280             TrySwitchViewL();
       
  2281             break;
       
  2282             }
       
  2283           // -----------------------------
       
  2284           case ECamImageCaptureTimeLapse:
       
  2285             {
       
  2286             iTargetViewState = ECamViewStatePostCapture;
       
  2287             TrySwitchViewL();
       
  2288             break;
       
  2289             }      
       
  2290           // -----------------------------
       
  2291           case ECamImageCaptureSingle:
       
  2292             {
       
  2293             PRINT( _L("Camera <> case ECamImageCaptureSingle") )
       
  2294             if( aError != KErrNone )
       
  2295               {
       
  2296               PRINT( _L("Camera <> error received") )
       
  2297               // handle error if necessary
       
  2298               HandleCameraErrorL( aError );
       
  2299               
       
  2300               iPreventActivePaletteDisplay = EFalse;
       
  2301               SetActivePaletteVisibility( ETrue );   
       
  2302                     
       
  2303    			  if (iCamOrientation == ECamOrientationPortrait) 
       
  2304    			   {
       
  2305     		   iTargetViewState = ECamViewStatePrePortraitCapture;
       
  2306    		       }
       
  2307   			  else
       
  2308      		   {
       
  2309     		   iTargetViewState = ECamViewStatePreCapture;   	
       
  2310     		   }
       
  2311             TrySwitchViewL();
       
  2312               }       
       
  2313             else
       
  2314               {
       
  2315               PRINT( _L("Camera <> no errors in") )
       
  2316               if ( !ShowPostCaptureView() && 
       
  2317                    iInSelfTimerMode == ECamSelfTimerDisabled && 
       
  2318                    !IsSelfTimedCapture() )
       
  2319                 {
       
  2320                 PRINT( _L("Camera <> update cba") )
       
  2321                 UpdateCba();
       
  2322 				if( ActiveCamera() != ECamActiveCameraPrimary )
       
  2323 					{
       
  2324 	                PRINT( _L("Camera <> release array") )
       
  2325 	                iController.ReleaseArray();
       
  2326 					}
       
  2327                 iPreventActivePaletteDisplay = EFalse;
       
  2328                 SetActivePaletteVisibility( ETrue );   
       
  2329                 if ( iController.IsTouchScreenSupported() )
       
  2330                     {
       
  2331                     CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  2332                     if ( fixedToolbar )
       
  2333                         {
       
  2334                         fixedToolbar->SetToolbarVisibility( ETrue );
       
  2335                         }
       
  2336                     }
       
  2337                 HandleCommandL( ECamCmdRaiseCourtesyUI );
       
  2338                 if ( IsSecondCameraEnabled() || IsEmbedded() )
       
  2339                     {
       
  2340                     //For secondary or embedded camera the viewfinder
       
  2341                     //was stopped. Restart it now.
       
  2342                     iController.StartViewFinder(); 
       
  2343                     }
       
  2344                 }
       
  2345               else if ( !ShowPostCaptureView() && 
       
  2346                        iInSelfTimerMode != ECamSelfTimerDisabled )
       
  2347                 {
       
  2348                 SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2349                 }
       
  2350               }
       
  2351             break;
       
  2352             }
       
  2353           // -----------------------------
       
  2354           default:
       
  2355             {
       
  2356             // do nothing
       
  2357             break;
       
  2358             }
       
  2359           // -----------------------------
       
  2360           }
       
  2361         }
       
  2362             // reset the selftimed capture flag for next capture
       
  2363             PRINT( _L("resetting iSelfTimedCapture") )
       
  2364             iSelfTimedCapture = EFalse;
       
  2365       break;
       
  2366       }     
       
  2367     // -----------------------------
       
  2368     case ECamEventControllerReady: 
       
  2369         {
       
  2370         if ( iView )
       
  2371             {
       
  2372             if ( iFirstBoot && IsSecondCameraEnabled() 
       
  2373                             && IsQwerty2ndCamera()
       
  2374                             && CurrentViewState() != ECamViewStateStandby )
       
  2375                 {
       
  2376                 PRINT( _L("Camera <> Booting directly to the secondary camera") )  
       
  2377                 // Main camera settings are loades as default. 
       
  2378                 // Need to be updated to secondary
       
  2379                 iStillCaptureView->CreateAndSetToolbarL( 
       
  2380                                     R_CAM_STILL_PRECAPTURE_TOOLBAR_LANDSCAPE );
       
  2381                 iVideoCaptureView->CreateAndSetToolbarL( 
       
  2382                                     R_CAM_VIDEO_PRECAPTURE_TOOLBAR_LANDSCAPE );
       
  2383                 // Add toolbar observer. Needed in first boot to secondary
       
  2384                 SetPreCaptureMode( ECamPreCapViewfinder ); 
       
  2385                 }
       
  2386             iFirstBoot = EFalse;
       
  2387             iView->HandleCommandL( ECamCmdPopUpMenuZoom );
       
  2388             }
       
  2389         //Remaining recording time counter update needed when recording has stopped and
       
  2390         //show last captured video setting is off.
       
  2391         if( iNaviPaneCounterControl && !ShowPostCaptureView() && iMode == ECamControllerVideo )
       
  2392             {
       
  2393             iNaviPaneCounterControl->ForceNaviPaneUpdate();
       
  2394             }        
       
  2395         break;
       
  2396         }      
       
  2397     // -----------------------------        
       
  2398     // -----------------------------------------------------
       
  2399     // The MMC is removed
       
  2400     case ECamEventMemoryCardHotswap:
       
  2401         {
       
  2402         TBool mmcInUse = EFalse;
       
  2403 
       
  2404         TCamMediaStorage currentLocation = 
       
  2405             static_cast<TCamMediaStorage>( 
       
  2406             iController.IntegerSettingValueUnfiltered( 
       
  2407                                           ECamSettingItemVideoMediaStorage ) );
       
  2408 
       
  2409         // if app is in back show MMC note on returning to foreground
       
  2410         PRINT( _L("Camera => CCamAppUi::HandleControllerEventL ECamEventMMCHotswap") )
       
  2411         if ( currentLocation == ECamMediaStorageCard )
       
  2412             {
       
  2413             if ( AppInBackground( ETrue ) && iReturnFromBackground )
       
  2414                 {
       
  2415                 PRINT( _L("Camera => CCamAppUi::HandleControllerEventL ECamEventMMCHotswap bckgrn") )
       
  2416                 //iMMCRemoveNoteRequired = ETrue;
       
  2417   
       
  2418                 // Force use of phone memory.
       
  2419                 // with multiple drive support, 
       
  2420                 // this actually uses the internal mass memory
       
  2421                iController.UsePhoneMemoryL();
       
  2422                }
       
  2423         else // show note on next capture attempt
       
  2424             {
       
  2425             PRINT( _L("Camera => CCamAppUi::HandleControllerEventL ECamEventMMCHotswap not bckgrnd") )
       
  2426             iMMCRemoveNoteRequiredOnCapture = ETrue;
       
  2427 
       
  2428             // force update of navi pane
       
  2429             iNaviPaneCounterControl->ForceNaviPaneUpdate();
       
  2430             if ( IsDirectViewfinderActive() )
       
  2431                 {
       
  2432                 TRAP_IGNORE( HandleCommandL( ECamCmdRedrawScreen ) );
       
  2433                 }
       
  2434             }
       
  2435         }
       
  2436 
       
  2437         // if the current mode is video, and the storage location is MMC
       
  2438         if ( ECamControllerVideo == iMode )
       
  2439             {
       
  2440             mmcInUse = (ECamMediaStorageCard == currentLocation);
       
  2441             }
       
  2442            // if the current mode is still, and the storage location is MMC
       
  2443         else        
       
  2444             {
       
  2445             mmcInUse = ( ECamMediaStorageCard == 
       
  2446                        iController.IntegerSettingValueUnfiltered( 
       
  2447                            ECamSettingItemPhotoMediaStorage ) );
       
  2448             }
       
  2449 
       
  2450         // If a post capture view is active, and the current files
       
  2451         // are saved to the MMC, switch to pre capture view
       
  2452         if ( mmcInUse
       
  2453              && ( ECamViewStateBurstThumbnail == iViewState
       
  2454              || ECamViewStatePostCapture    == iViewState )
       
  2455            )
       
  2456             {
       
  2457             if (iCamOrientation == ECamOrientationPortrait) 
       
  2458                 {
       
  2459                 iTargetViewState = ECamViewStatePrePortraitCapture;
       
  2460                 }
       
  2461             else
       
  2462                 {
       
  2463                 iTargetViewState = ECamViewStatePreCapture;   	
       
  2464                 }
       
  2465             TrySwitchViewL();
       
  2466             }
       
  2467         break;            
       
  2468         }
       
  2469     // -----------------------------------------------------
       
  2470     case ECamEventCounterUpdated:
       
  2471         break;
       
  2472     // -----------------------------------------------------
       
  2473     case ECamEventVideoPauseTimeout:
       
  2474         {
       
  2475         PRINT( _L( "Camera <> case ECamEventVideoPauseTimeout" ) )
       
  2476         EndCapture();
       
  2477         break;
       
  2478         }
       
  2479     // -----------------------------------------------------
       
  2480     case ECamEventSaveLocationChanged:
       
  2481         {
       
  2482         PRINT( _L( "Camera <> case ECamEventSaveLocationChanged" ) )
       
  2483         if ( IsMMCRemovedNotePending() && 
       
  2484            ( CamUtility::MemoryCardStatus() != ECamMemoryCardNotInserted ) )
       
  2485             {
       
  2486             iMMCRemoveNoteRequired = EFalse;
       
  2487             iMMCRemoveNoteRequiredOnCapture = EFalse;
       
  2488             }
       
  2489         if ( IsDirectViewfinderActive() )
       
  2490             {
       
  2491             TRAP_IGNORE( HandleCommandL( ECamCmdRedrawScreen ) );
       
  2492             }
       
  2493         break;
       
  2494         }   
       
  2495 
       
  2496     // -----------------------------------------------------
       
  2497     case ECamEventSaveComplete:
       
  2498         {
       
  2499         PRINT( _L( "Camera <> case ECamEventSaveComplete" ) )
       
  2500         if ( ECamImageCaptureSingle == iImageMode )
       
  2501             {
       
  2502             if( iController.CaptureKeyPressedWhileImageSaving() && 
       
  2503                 ShowPostCaptureView())
       
  2504                 {
       
  2505                 PRINT( _L("Camera <> HandleControllerEventL ECamEventSaveComplete - Capture key pressed while saving ") )
       
  2506                 iController.SetCaptureKeyPressedWhileImageSaving(EFalse);
       
  2507                 if (iCamOrientation == ECamOrientationPortrait)  
       
  2508                     {
       
  2509                     iTargetViewState = ECamViewStatePrePortraitCapture;
       
  2510                     }
       
  2511                 else
       
  2512                     {
       
  2513                     iTargetViewState = ECamViewStatePreCapture;   	
       
  2514                     }
       
  2515                TrySwitchViewL();
       
  2516                }
       
  2517             }
       
  2518         break;
       
  2519         }
       
  2520     // -----------------------------------------------------
       
  2521     case ECamEventMediaFileChanged:
       
  2522         {
       
  2523  
       
  2524         if ( iController.UiConfigManagerPtr() && 
       
  2525              !iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  2526             {
       
  2527             PRINT2( _L( "Camera <> CCamAppU, ECamEventMediaFileChanged, mode [%s], targetmode[%s]" ), 
       
  2528                 KCamModeNames[ iController.CurrentMode() ], 
       
  2529                 KCamModeNames[ iController.TargetMode() ] )
       
  2530     	  
       
  2531             if( iEndKeyPressed )
       
  2532                 {
       
  2533                 if ( iController.CurrentMode() == ECamControllerShutdown || 
       
  2534                      iController.IsInShutdownMode() )
       
  2535                     {
       
  2536                     PRINT( _L( "Camera <> ECamEventMediaFileChanged, notify shutdown" ) )
       
  2537                     HandleControllerEventL( ECamEventExitRequested, KErrNone );
       
  2538                     }
       
  2539                 }
       
  2540             }
       
  2541  
       
  2542       if ( iController.UiConfigManagerPtr() && iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  2543           {
       
  2544           // If record location setting is on, stop location trail
       
  2545           if ( ECamViewStatePreCapture != iViewState && ECamLocationOn == iController.IntegerSettingValue( ECamSettingItemRecLocation ) )
       
  2546           	  {
       
  2547           	  PRINT( _L("Camera: Gallery notified and non pre-capture view, stop location trail") )
       
  2548           	  iController.StopLocationTrail();
       
  2549           	  }
       
  2550           else
       
  2551           	  {
       
  2552               PRINT1( _L("Camera: location trail not in use or view state (%d) is precapture"), iViewState )
       
  2553           	  }
       
  2554           }
       
  2555 
       
  2556         break;
       
  2557         }
       
  2558     // -----------------------------------------------------
       
  2559     case ECamEventCameraChanged:
       
  2560         {
       
  2561         PRINT( _L("Camera <> case ECamEventCameraChanged"))
       
  2562         // exit standby and use the new camera
       
  2563         if( iView)
       
  2564             {
       
  2565             iView->HandleCommandL( ECamCmdExitStandby );
       
  2566             }
       
  2567         break;
       
  2568         }
       
  2569     // -----------------------------------------------------
       
  2570     case ECamEventInvalidMemoryCard:
       
  2571         {
       
  2572         PRINT( _L( "Camera <> case ECamEventInvalidMemoryCard" ) ); 
       
  2573         ShowErrorNoteL( ECamMemoryStatusCardNotInserted );
       
  2574         break;
       
  2575         }
       
  2576     // -----------------------------------------------------
       
  2577     case ECamEventRestoreCameraSettings:
       
  2578         {
       
  2579         PRINT( _L( "Camera <> case ECamEventRestoreCameraSettings" ) ); 
       
  2580         if ( SettingsLaunchedFromCamera() )
       
  2581             {
       
  2582             iSettingsPluginLaunched = EFalse;
       
  2583             iReturnedFromPlugin = ETrue;
       
  2584             } 
       
  2585         iTargetViewState = ECamViewStatePreCapture;
       
  2586           
       
  2587         // get start up mode from settings
       
  2588         if ( StartupMode() == ECamStillCapture )
       
  2589             {
       
  2590             iMode       = ECamControllerImage;
       
  2591             iTargetMode = ECamControllerImage;
       
  2592             SetDefaultViewL( *iStillCaptureView );
       
  2593             }
       
  2594         else
       
  2595             {
       
  2596             iMode       = ECamControllerVideo;
       
  2597             iTargetMode = ECamControllerVideo;
       
  2598             SetDefaultViewL( *iVideoCaptureView );
       
  2599             }
       
  2600             
       
  2601         TrySwitchViewL();
       
  2602         // After restoring settings, still capture view should be active 
       
  2603         // -> Update all toolbar icons for still-capture view. 
       
  2604         iStillCaptureView->UpdateToolbarIconsL();
       
  2605         break;
       
  2606         }
       
  2607     // -----------------------------------------------------
       
  2608     case ECamEventCallStateChanged:
       
  2609         SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2610         break;
       
  2611     // -----------------------------------------------------
       
  2612     default:
       
  2613         break;
       
  2614     // -----------------------------------------------------
       
  2615     }
       
  2616     PRINT( _L( "Camera: <= CCamAppUi::HandleControllerEventL()" ) );         
       
  2617   }
       
  2618 
       
  2619 // -----------------------------------------------------------------------------
       
  2620 // HandleStandbyEventL
       
  2621 // -----------------------------------------------------------------------------
       
  2622 //
       
  2623 void
       
  2624 CCamAppUi::HandleStandbyEventL( TInt aStatus )
       
  2625   {
       
  2626   PRINT( _L( "Camera => CCamAppUi::HandleStandbyEventL") );
       
  2627   if( !iPretendExit &&
       
  2628       !AppInBackground( EFalse )  )
       
  2629     {
       
  2630     if( ECamViewStateStandby != iViewState )
       
  2631       {
       
  2632       DismissMemoryNoteL();  
       
  2633     
       
  2634       if( IsInternalView( iViewState ) )
       
  2635         {
       
  2636          
       
  2637         if ( aStatus != KErrInUse &&
       
  2638              iPreCaptureMode == ECamPreCapCaptureSetup ||
       
  2639              iPreCaptureMode == ECamPreCapSceneSetting )
       
  2640             {
       
  2641             // VF settings does not go to standby state, VF is stopped instead
       
  2642             // Screen saver releases resources
       
  2643             iViewFinderStopped = ETrue;
       
  2644             PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: in one of settings view. Release camera") );
       
  2645             iController.ReleaseCamera();
       
  2646             //Draw black viewfinder area. Because camera is in internal viewstate view is valid.
       
  2647             static_cast<CCamViewBase*>( iView )->HandleCommandL( ECamCmdRedrawScreen );
       
  2648             }         
       
  2649         else 
       
  2650             {
       
  2651             PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: call iView->ExitAllModesL") );
       
  2652             PRINT1( _L( "Camera <> CCamAppUi::HandleStandbyEventL: iView = 0x%x"), iView );
       
  2653             // Exit any special modes.
       
  2654             // If AppUI construction is not finished, do it first, otherwise
       
  2655             // the view has not been created yet
       
  2656             if ( iController.UiConfigManagerPtr() && 
       
  2657                  iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() &&
       
  2658                  !iUiConstructionComplete )
       
  2659               {
       
  2660               CompleteAppUIConstructionL(); 
       
  2661               }
       
  2662             else
       
  2663               {    
       
  2664               static_cast<CCamViewBase*>( iView )->ExitAllModesL();
       
  2665               }
       
  2666              
       
  2667             }
       
  2668         }
       
  2669       // Not InternalView
       
  2670       else 
       
  2671         {
       
  2672         PRINT( _L( "Camera <= CCamAppUi::HandleStandbyEventL: Not internalView, standby ignored, return") );
       
  2673         return;
       
  2674         }
       
  2675       
       
  2676       // VF settings does not go to standby state, VF is stopped instead
       
  2677       if ( aStatus == KErrInUse || iPreCaptureMode != ECamPreCapCaptureSetup &&
       
  2678            iPreCaptureMode != ECamPreCapSceneSetting )  
       
  2679            {
       
  2680            PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: Set standby status..") );
       
  2681            SetStandbyStatus( aStatus );
       
  2682            if ( iController.InVideocallOrRinging() && iScreenClearer )
       
  2683              {
       
  2684              delete iScreenClearer;
       
  2685              iScreenClearer = NULL;
       
  2686              }
       
  2687            
       
  2688            PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: Send command ECamCmdGoToStandby..") );
       
  2689            HandleCommandL( ECamCmdGoToStandby );
       
  2690            }
       
  2691        }
       
  2692     else
       
  2693       {
       
  2694       PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: Already in standby, ignored!") );
       
  2695       }
       
  2696     }
       
  2697   else
       
  2698     {
       
  2699     PRINT( _L( "Camera <> CCamAppUi::HandleStandbyEventL: Camera already in background, no action..") );    
       
  2700     }
       
  2701   PRINT( _L( "Camera <= CCamAppUi::HandleStandbyEventL") );
       
  2702   } 
       
  2703 
       
  2704 // -----------------------------------------------------------------------------
       
  2705 // SetStandbyStatus
       
  2706 // -----------------------------------------------------------------------------
       
  2707 //
       
  2708 void CCamAppUi::SetStandbyStatus( TInt aStatus )
       
  2709   {
       
  2710   PRINT1( _L( "Camera =><= CCamAppUi::SetStandbyStatus( %d )"), aStatus );
       
  2711   iStandbyStatus = aStatus;
       
  2712   }
       
  2713 
       
  2714 // -----------------------------------------------------------------------------
       
  2715 // StandbyStatus
       
  2716 // -----------------------------------------------------------------------------
       
  2717 //
       
  2718 TInt CCamAppUi::StandbyStatus() const
       
  2719   {
       
  2720   return iStandbyStatus;
       
  2721   }
       
  2722 
       
  2723 // ---------------------------------------------------------
       
  2724 // CCamAppUi::IsEmbedded
       
  2725 // Retrun whether we are embedded or not
       
  2726 // ---------------------------------------------------------
       
  2727 //
       
  2728 TBool CCamAppUi::IsEmbedded() const
       
  2729   {
       
  2730   PRINT( _L("Camera => CCamAppUi::IsEmbedded") );
       
  2731 /*#ifndef __WINS__
       
  2732   PRINT1( _L("CCamAppUi::IsEmbedded %d"), iSendFileInCall );
       
  2733   // treat inCallSend mode as same as embedded
       
  2734   if( iSendFileInCall )
       
  2735     {
       
  2736     PRINT( _L("CCamAppUi::IsEmbedded iCall" ) );
       
  2737     return ETrue;
       
  2738     }
       
  2739 #endif*/
       
  2740   PRINT( _L("Camera <= CCamAppUi::IsEmbedded") );
       
  2741   return iEikonEnv->StartedAsServerApp();
       
  2742   }
       
  2743 
       
  2744 
       
  2745 // ---------------------------------------------------------
       
  2746 // ---------------------------------------------------------
       
  2747 // CCamAppUi::HandleWsEventL
       
  2748 // Handle a window server event. Used to handle focus loss
       
  2749 // ---------------------------------------------------------
       
  2750 //
       
  2751 void 
       
  2752 CCamAppUi::HandleWsEventL( const TWsEvent&    aEvent,
       
  2753                                  CCoeControl* aDestination )
       
  2754   {
       
  2755     
       
  2756   TInt type = aEvent.Type();
       
  2757   
       
  2758   PRINT1( _L("Camera => CCamAppUi::HandleWsEventL (type: %d)"), type )
       
  2759   // In case we receive an enter key event, we should map it to MSK
       
  2760   if ( aEvent.Type() == EEventKey && aEvent.Key()->iRepeats == 0 && 
       
  2761        aEvent.Key()->iScanCode == EStdKeyEnter &&
       
  2762        !( iMode == ECamControllerVideo && iViewState == ECamViewStatePreCapture && iController.IsDemandKeyRelease() ) ) 
       
  2763     {
       
  2764     PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: mapping enter to MSK") );
       
  2765     // Gets the window group id of the app in foreground
       
  2766     TInt windowGroupId = iCoeEnv->WsSession().GetFocusWindowGroup();
       
  2767     // if the foreground app is this app
       
  2768     if ( windowGroupId == iMyWgId ) 
       
  2769         {
       
  2770         // enter key should be mapped to MSK.
       
  2771         TWsEvent  ownEvent = aEvent;
       
  2772         ownEvent.Key()->iScanCode = EStdKeyDevice3;
       
  2773         ownEvent.Key()->iCode = EKeyOK;
       
  2774         iCoeEnv->WsSession().SendEventToWindowGroup(windowGroupId, ownEvent);
       
  2775         }
       
  2776     }
       
  2777   // in case we receive a long press of applications key when the self timer is 
       
  2778   // enabled, we should cancel the self timer
       
  2779   else if ( aEvent.Type() == EEventKey &&
       
  2780             aEvent.Key()->iScanCode == EStdKeyApplication0 &&
       
  2781             aEvent.Key()->iRepeats > 0 && 
       
  2782             SelfTimerEnabled() )
       
  2783         {
       
  2784         SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2785         }
       
  2786   // in other cases do the normal handling
       
  2787   else 
       
  2788     {
       
  2789 
       
  2790       switch ( type )
       
  2791         { 
       
  2792         // a new window group has the focus
       
  2793         case EEventFocusGroupChanged:
       
  2794           {
       
  2795           PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: case EEventFocusGroupChanged") );
       
  2796                 
       
  2797           // When camera looses its focus after going to background
       
  2798           // during the state of ViaPlayer play back mode
       
  2799           // we dont perform any operation; but return directly      
       
  2800           if ( iViewState == ECamViewStateViaPlayer )
       
  2801             {
       
  2802             // We call the base class and return
       
  2803             CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  2804             return;
       
  2805             }
       
  2806                 
       
  2807           // When camera looses its focus after going to background
       
  2808           // we return to the same settings page that was before       
       
  2809           if ( SettingsLaunchedFromCamera() )
       
  2810           	{
       
  2811           	// We call the base class and return
       
  2812           	CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  2813           	return;
       
  2814           	}
       
  2815           // we are going to background no need for harvester callbacks.
       
  2816           iController.DeRegisterHarverterClientEvents();
       
  2817     
       
  2818           if ( AppInBackground( ETrue ) && iPretendExit )
       
  2819             {
       
  2820             //Make the current container invisible to prevent windowserver from bringing it to front
       
  2821             //before the foreground event.
       
  2822             TVwsViewId currentViewId;
       
  2823             GetActiveViewId( currentViewId );
       
  2824             switch ( currentViewId.iViewUid.iUid )
       
  2825                 {
       
  2826                 case ECamViewIdStillPreCapture:
       
  2827                     {
       
  2828                     if( iStillCaptureView->Container() && 
       
  2829                         !APHandler()->AccessedViaAP() )
       
  2830                         {
       
  2831                         iStillCaptureView->Container()->MakeVisible( EFalse );
       
  2832                         }
       
  2833                     iLastHiddenViewId = currentViewId.iViewUid;
       
  2834                     break;
       
  2835                     }
       
  2836                 case ECamViewIdStillPostCapture:
       
  2837                     {
       
  2838                     CCamStillPostCaptureView* stillPostCaptureView = 
       
  2839                     ((CCamStillPostCaptureView*)View( currentViewId.iViewUid ));
       
  2840                     if( stillPostCaptureView && stillPostCaptureView->Container() )
       
  2841                         {
       
  2842                         stillPostCaptureView->Container()->MakeVisible( EFalse );
       
  2843                         }
       
  2844                     iLastHiddenViewId = currentViewId.iViewUid;
       
  2845                     break;
       
  2846                     }
       
  2847                 case ECamViewIdVideoPreCapture:
       
  2848                     {
       
  2849                     if( iVideoCaptureView->Container() && 
       
  2850                         !APHandler()->AccessedViaAP() )
       
  2851                         {
       
  2852                         iVideoCaptureView->Container()->MakeVisible( EFalse );
       
  2853                         }
       
  2854                     iLastHiddenViewId = currentViewId.iViewUid;
       
  2855                     break;
       
  2856                     }
       
  2857                 case ECamViewIdVideoPostCapture:
       
  2858                     {
       
  2859                     CCamVideoPostCaptureView* videoPostCaptureView = 
       
  2860                      ((CCamVideoPostCaptureView*)View( currentViewId.iViewUid ));
       
  2861                      if( videoPostCaptureView && videoPostCaptureView->Container() )
       
  2862                          {
       
  2863                          videoPostCaptureView->Container()->MakeVisible( EFalse );
       
  2864                          }
       
  2865                     iLastHiddenViewId = currentViewId.iViewUid;
       
  2866                     break;
       
  2867                     }
       
  2868                 default:
       
  2869                     break;
       
  2870                 }
       
  2871             }
       
  2872 
       
  2873           // if the application has gone to the background
       
  2874           // note this does not include eikon server windows
       
  2875           // The exception to this is when the slider is closed with keypad 
       
  2876           // lock active and the app grid opens with a keypad status note. 
       
  2877           // We know in this situation that the app should release resources.
       
  2878           if ( AppInBackground( EFalse ) || 
       
  2879              ( AppInBackground( ETrue ) && iPretendExit ) )
       
  2880             {
       
  2881             PRINT( _L("Camera <> AppUI EEventFocusGroupChanged A"))
       
  2882             // when we return to foreground we use this boolean to
       
  2883             // check if we have to still exit the settings modes e.g. 
       
  2884             // UserScene or SceneSettings that we are in when screen saver 
       
  2885             // comes or going InternalExit
       
  2886             iLostFocusToNewWindow = ETrue;
       
  2887               
       
  2888             // Handle losing focus to another application
       
  2889             // this is used for behaviour that does not need to occur
       
  2890             // when views go to the background for another view within our
       
  2891             // own application. Also for when the application was behind
       
  2892             // an eikon server window but another application has now taken
       
  2893             // the foreground
       
  2894     
       
  2895             if( iView && iReturnedFromPlugin )
       
  2896               {
       
  2897               PRINT( _L("Camera <> AppUI EEventFocusGroupChanged B"))
       
  2898               static_cast<CCamViewBase*>( iView )->HandleFocusLossL();
       
  2899               }
       
  2900     
       
  2901             // the application knows it is in the background so we are
       
  2902             // not interested in any more events
       
  2903             iCoeEnv->RootWin().DisableFocusChangeEvents();
       
  2904             // disable timeout to standby when going to background
       
  2905             iController.StopIdleTimer();
       
  2906       
       
  2907             // We need to know if we gain focus from a true background event
       
  2908             iReturnFromBackground = ETrue;  
       
  2909             // Sent to the background, so compress the heap
       
  2910             User::Heap().Compress();                
       
  2911               
       
  2912             // stop listening mmc dismount notifications
       
  2913             iController.CancelDismountMonitoring();
       
  2914       
       
  2915     #if !defined (__WINSCW__)
       
  2916             if ( AppInBackground( ETrue ) )     
       
  2917               {
       
  2918               // relinquish capture keys
       
  2919               UnRegisterCaptureKeys();    
       
  2920               }
       
  2921     #endif
       
  2922             }
       
  2923     
       
  2924           if( AppInBackground(EFalse) || ( !CamUtility::IsBatteryPowerOK() && 
       
  2925                                            !CamUtility::IsBatteryCharging() ) )
       
  2926             {
       
  2927             if( ECamControllerVideo == iMode )
       
  2928               {
       
  2929               TCamCaptureOperation operation( iController.CurrentOperation() );
       
  2930               // In case of phone app, video rec is stopped already when the call starts ringing
       
  2931               if ( ( !iController.CurrentlySavingVideo() ) && 
       
  2932                  ( ECamCapturing == operation 
       
  2933                 || ECamPaused    == operation 
       
  2934                 || ECamPausing   == operation 
       
  2935                 || ECamResuming  == operation ) )
       
  2936                 {
       
  2937                 iController.StopVideoRecording();
       
  2938                 }
       
  2939               }
       
  2940             else if( iController.SequenceCaptureInProgress() && IsBurstEnabled() )
       
  2941               {
       
  2942               iController.StopSequenceCaptureL();
       
  2943               }
       
  2944             else
       
  2945               {
       
  2946               if( iController.IsViewFinding() )
       
  2947                 {
       
  2948                 if(CamUtility::IsBatteryPowerOK() )         
       
  2949                   {
       
  2950                   iController.StopViewFinder();
       
  2951                   iViewFinderStopped = ETrue;	
       
  2952                   }
       
  2953                 // stop self timer countdown if necessary
       
  2954                 if( SelfTimer() && SelfTimer()->IsActive() && 
       
  2955                     CamUtility::IsBatteryPowerOK() )
       
  2956                   {
       
  2957                   // If low battery note appears, do not cancel self timer
       
  2958                   SelfTimerEnableL( ECamSelfTimerDisabled );
       
  2959                   }
       
  2960                 }
       
  2961               }
       
  2962             }
       
  2963           break;
       
  2964           }
       
  2965         // -----------------------------------------------------
       
  2966         // the camera app has regained the focus
       
  2967         case EEventFocusGained:
       
  2968           {            
       
  2969           PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: case EEventFocusGained") );
       
  2970           TBool uiOverride = iController.UiConfigManagerPtr() && iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported();
       
  2971           
       
  2972           if ( !iSendAsInProgress )
       
  2973               {
       
  2974               // if we've regained focus assume we're not embedding anything
       
  2975               SetEmbedding( EFalse ); 
       
  2976               }
       
  2977           
       
  2978           //Make the current container visible again. This way the camera ui doesn't flash quickly in the portait mode
       
  2979           //when returning from the background. unless this is first startup and uiorientationioverride api is used
       
  2980           if ( !uiOverride || ( !iFirstBoot && uiOverride ) )
       
  2981               {
       
  2982               switch ( iLastHiddenViewId.iUid )
       
  2983                   {
       
  2984                   case ECamViewIdStillPreCapture:
       
  2985                       {
       
  2986                       if( iStillCaptureView->Container() 
       
  2987                           && !APHandler()->AccessedViaAP())
       
  2988                           {
       
  2989                           iStillCaptureView->Container()->MakeVisible( ETrue );
       
  2990                           }
       
  2991                       break;
       
  2992                       }
       
  2993                   case ECamViewIdStillPostCapture:
       
  2994                       {
       
  2995                       CCamStillPostCaptureView* stillPostCaptureView = 
       
  2996                       ((CCamStillPostCaptureView*)View( iLastHiddenViewId ));
       
  2997                       if( stillPostCaptureView && stillPostCaptureView->Container() )
       
  2998                           {
       
  2999                           stillPostCaptureView->Container()->MakeVisible( ETrue );
       
  3000                           }
       
  3001                       break;
       
  3002                       }
       
  3003                   case ECamViewIdVideoPreCapture:
       
  3004                       {
       
  3005                   if( iVideoCaptureView->Container() 
       
  3006                       && !APHandler()->AccessedViaAP())
       
  3007                           {
       
  3008                           iVideoCaptureView->Container()->MakeVisible( ETrue );
       
  3009                           }
       
  3010                       break;
       
  3011                       }
       
  3012                   case ECamViewIdVideoPostCapture:
       
  3013                       {
       
  3014                       CCamVideoPostCaptureView* videoPostCaptureView = 
       
  3015                        ((CCamVideoPostCaptureView*)View( iLastHiddenViewId ));
       
  3016                        if( videoPostCaptureView && videoPostCaptureView->Container() )
       
  3017                            {
       
  3018                            videoPostCaptureView->Container()->MakeVisible( ETrue );
       
  3019                            }
       
  3020                       break;
       
  3021                       }
       
  3022                   default:
       
  3023                       break;
       
  3024                   }
       
  3025               }
       
  3026           // focus gained event is received while videocall is active
       
  3027           if ( iController.InVideocallOrRinging() )
       
  3028               {
       
  3029               if ( ECamViewStateStandby == iViewState && 
       
  3030                    StandbyStatus() == KErrInUse )
       
  3031                   { 
       
  3032                   // We call the base class and return
       
  3033                   CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3034                   return;
       
  3035                   }
       
  3036               else if ( iViewState != ECamViewStateSettings && 
       
  3037                         iViewState != ECamViewStateViaPlayer &&
       
  3038                         iTargetViewState != ECamViewStatePostCapture &&
       
  3039                        !iFirstBoot )
       
  3040                   {
       
  3041                   //Don't update task state in case of embedded camera
       
  3042                   if ( !iEikonEnv->StartedAsServerApp())
       
  3043                       {
       
  3044                       HideTaskL( EFalse );
       
  3045                       }
       
  3046                   iPretendExit = EFalse; 	
       
  3047                   // Go to standby with error	
       
  3048                   HandleStandbyEventL( KErrInUse );
       
  3049                   // We call the base class and return
       
  3050                   CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3051                   return;
       
  3052                   } 
       
  3053               }
       
  3054           // Only do startup performance traces if this is
       
  3055           // a subsequent startup.
       
  3056           if ( IsInPretendExit() )
       
  3057               {
       
  3058               OstTrace0( CAMERAAPP_PERFORMANCE, CCAMAPPUI_HANDLEWSEVENTL, "e_CAM_APP_INIT 1" ); //CCORAPP_APP_INIT_START
       
  3059               }
       
  3060               
       
  3061           PERF_EVENT_START_L1( EPerfEventAppSubsequentStartup );
       
  3062                 
       
  3063          // start listening mmc dismount notifications
       
  3064          iController.StartDismountMonitoring();	 
       
  3065                
       
  3066           if ( !uiOverride || ( !iFirstBoot && uiOverride ) )
       
  3067               {      
       
  3068               NotifyViews( ECamAppEventFocusGained );
       
  3069               if( !uiOverride )
       
  3070                   {
       
  3071                   // whenever we come from background, we reset the image, 
       
  3072                   // video & common settings as there is a possibility that 
       
  3073                   // some settings might have changed from the GS application
       
  3074                   // by the user.
       
  3075                   iController.LoadStaticSettingsL( IsEmbedded() );
       
  3076                   }
       
  3077                     
       
  3078               iStillCaptureView->UpdateToolbarIconsL();
       
  3079               if( !uiOverride )
       
  3080                   {
       
  3081                   //check for silent profile whenever we come to foreground.
       
  3082                   iController.IsProfileSilent();
       
  3083                   }
       
  3084               }                  
       
  3085               
       
  3086           //Check existance of current file if in video or image in 
       
  3087           //burstthumbnail view.      
       
  3088           if( CurrentViewState() == ECamViewStateBurstThumbnail  )
       
  3089               {
       
  3090               StartFileNameCheck();
       
  3091               }
       
  3092           /*
       
  3093           * We check if the state of the camera is in the ViaPlayer mode state
       
  3094           * if so, then we just activate the player view and return after
       
  3095           * coming from the background.
       
  3096           */
       
  3097           if ( iViewState == ECamViewStateViaPlayer )
       
  3098               {
       
  3099               ActivateLocalViewL ( iViaPlayerUid );
       
  3100               // We call the base class and return
       
  3101               CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3102               return;
       
  3103               }
       
  3104           else if ( iTargetViewState == ECamViewStatePostCapture  )
       
  3105               {
       
  3106               TrySwitchViewL( ETrue );
       
  3107               // register an interest in new events
       
  3108               iCoeEnv->RootWin().EnableFocusChangeEvents();   // ignore error
       
  3109                 
       
  3110 #if !defined (__WINSCW__)
       
  3111               // Grab capture keys
       
  3112               RegisterCaptureKeysL();    
       
  3113     
       
  3114 #endif             
       
  3115               // iPretendExit flag needs to be reset before returning, otherwise
       
  3116               // views think we are still in exit state and will not reserve camera
       
  3117               iPretendExit = EFalse;
       
  3118               CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3119               return;
       
  3120               }
       
  3121           else if ( SettingsLaunchedFromCamera() )
       
  3122               {
       
  3123               if ( iController.InVideocallOrRinging() && 
       
  3124                    iController.CurrentOperation() == ECamNoOperation )
       
  3125                   {
       
  3126                   iTargetViewState = ECamViewStatePreCapture;
       
  3127                   }
       
  3128               else
       
  3129                   {    
       
  3130                   CCamViewBase *precapView = static_cast<CCamViewBase*>( iView );
       
  3131 				  __ASSERT_DEBUG(precapView, CamPanic(ECamPanicNullPointer));
       
  3132                   if( precapView->IsInStandbyMode() )
       
  3133                 	  {
       
  3134                 	  iView->HandleCommandL( ECamCmdExitStandby );
       
  3135                 	  }
       
  3136                   iTargetViewState = ECamViewStateSettings;
       
  3137                   }
       
  3138               TrySwitchViewL();
       
  3139               CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3140               return;
       
  3141               }
       
  3142           else
       
  3143               {
       
  3144               // we are now sure that settings plugin is not active
       
  3145               iReturnedFromPlugin = ETrue;
       
  3146               }
       
  3147            
       
  3148          
       
  3149           if ( iLostFocusToNewWindow )
       
  3150               {            
       
  3151               if ( ECamViewStateBurstThumbnail != iTargetViewState )
       
  3152                   { 
       
  3153                   iLostFocusToNewWindow = EFalse;
       
  3154                   }
       
  3155               }
       
  3156           if( !uiOverride || ( !iFirstBoot && uiOverride ) )
       
  3157               {  
       
  3158               StartCheckingDefaultAlbumIdL();
       
  3159               }
       
  3160   
       
  3161           // Free the needed ram memory if not enough available
       
  3162           iMemoryMonitor->CheckAndRequestMemoryL(
       
  3163                            iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained(),
       
  3164                            iController.UiConfigManagerPtr()->RequiredRamMemoryFocusGained(),
       
  3165                            EFalse );
       
  3166 
       
  3167 
       
  3168           iController.SetEndKeyExitWaiting( EFalse );
       
  3169           //Don't update task state in case of embedded camera
       
  3170           if ( !iEikonEnv->StartedAsServerApp())
       
  3171               {
       
  3172               HideTaskL( EFalse );
       
  3173               }
       
  3174           // Restart the sensor idle
       
  3175           if ( iController.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
  3176               {
       
  3177               // Handle sensor api init when we have idle time
       
  3178               StartSensorIdleL();      
       
  3179               }
       
  3180                 
       
  3181           // the focus can be regained during a SendAs Bluetooth operation
       
  3182           // so don't try to exit the app if SendAs is in progress - the
       
  3183           // exit check will be performed once SendAs completes
       
  3184           // The same applies while a sequence capture is being completed
       
  3185           if ( !iSendAsInProgress && !iController.SequenceCaptureInProgress() )
       
  3186               {
       
  3187               PRINT( _L("Camera <> CCamAppUi::HandleWsEventL EEventFocusGained checking exit status") )
       
  3188               // check if exit is required
       
  3189               if ( iController.CheckExitStatus() )
       
  3190                   {
       
  3191                   InternalExitL();
       
  3192                   PRINT( _L("Camera <= CCamAppUi::HandleWsEventL, internal exit") )
       
  3193                   return;
       
  3194                   }
       
  3195               }
       
  3196                         
       
  3197           // register an interest in new events
       
  3198           iCoeEnv->RootWin().EnableFocusChangeEvents();   // ignore error
       
  3199                 
       
  3200     #if !defined (__WINSCW__)
       
  3201           // Grab capture keys
       
  3202           RegisterCaptureKeysL();    
       
  3203     
       
  3204     #endif             
       
  3205     
       
  3206           iReturnFromBackground = EFalse;
       
  3207 
       
  3208           // When the application gains focus
       
  3209           // the memory to use should be re-checked for 
       
  3210           // availability. If uioverride supported, check
       
  3211           // made later since settings not loaded at this point
       
  3212           if ( !uiOverride )
       
  3213               {
       
  3214               iController.CheckMemoryToUseL();
       
  3215               }
       
  3216                     
       
  3217           TBool returningFromPretendExit = iPretendExit;
       
  3218           iPretendExit = EFalse; 
       
  3219                  
       
  3220           TCamViewSwitch switchNeeded = ECamViewSwitchNone;               
       
  3221                                          
       
  3222           // if a view switch has been waiting for the application to get 
       
  3223           // the foreground.
       
  3224           if ( iPendingViewSwitch != EPendingViewSwitchNone && 
       
  3225                !iSendAsInProgress )
       
  3226               {
       
  3227               // In case the application is exited from portrait mode 
       
  3228               // and landscape should be used -> orientation switch is required 
       
  3229               TAppUiOrientation appOrientation = CAknAppUiBase::Orientation();
       
  3230               if ( EAppUiOrientationPortrait == appOrientation ) 
       
  3231                   {
       
  3232                   SwitchOrientationIfRequiredL( 
       
  3233                                  CAknAppUiBase::EAppUiOrientationUnspecified );
       
  3234                   }
       
  3235               TBool deactivateFirst = 
       
  3236                    ( iPendingViewSwitch == EPendingViewSwitchDeactivateFirst );
       
  3237               switchNeeded = ViewSwitchRequired( deactivateFirst );
       
  3238               iPendingViewSwitch = EPendingViewSwitchNone;
       
  3239               TrySwitchViewL( deactivateFirst );
       
  3240               }
       
  3241           else
       
  3242               {
       
  3243               if( iViewFinderStopped )
       
  3244                   {
       
  3245                   // don't start VF if EEventFocusGroupChanged is coming later
       
  3246                   if( !iLostFocusToNewWindow && 
       
  3247                       iController.CurrentMode() == ECamControllerImage || 
       
  3248                       iController.CurrentMode() == ECamControllerVideo ) 
       
  3249                       {
       
  3250                       iController.StartViewFinder(); 
       
  3251                       }
       
  3252                   iLostFocusToNewWindow = EFalse;
       
  3253                   }           
       
  3254               }    
       
  3255                     
       
  3256           // force side pane and active palette to update if simulating app 
       
  3257           // launch this has to be done after the call to TrySwitchViewL() to 
       
  3258           // ensure that IsBurstEnabled() returns the correct value.
       
  3259           if ( returningFromPretendExit )
       
  3260               {
       
  3261             /*if ( iController.UiConfigManagerPtr() && 
       
  3262                  iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  3263                 {
       
  3264                 // If record location setting is on, start location trail,
       
  3265                 // provided, primary camera and pre-capture view
       
  3266                 if ( ECamLocationOn == iController.IntegerSettingValue( ECamSettingItemRecLocation ) 
       
  3267                      && ECamActiveCameraPrimary == ActiveCamera() 
       
  3268             	     && ECamViewStatePreCapture == iViewState 
       
  3269             	   )
       
  3270                     {
       
  3271                   	iController.StartLocationTrailL();
       
  3272                     }
       
  3273                 }*/ 
       
  3274           
       
  3275             iCamSidePane->SetCaptureMode( iMode );
       
  3276             // The active palette is always switched on when simulating 
       
  3277             // app launch
       
  3278             iPreventActivePaletteDisplay = EFalse;                                
       
  3279     
       
  3280                
       
  3281             if ( iView == iVideoCaptureView )
       
  3282                 {
       
  3283                 iVideoCaptureView->UpdateToolbarIconsL();
       
  3284                 }
       
  3285             }
       
  3286 
       
  3287           if ( uiOverride && ( returningFromPretendExit || iFirstBoot ) )
       
  3288               {
       
  3289               SetActivePaletteVisibility( EFalse );               	
       
  3290               }
       
  3291           else if ( !TimeLapseSliderShown() && 
       
  3292                     iViewState == ECamViewStatePreCapture && 
       
  3293                     switchNeeded != ECamViewSwitch && 
       
  3294                     !uiOverride )
       
  3295               {
       
  3296               RaisePreCaptureCourtesyUI( ETrue );
       
  3297               }
       
  3298           
       
  3299           // If keylock is set on when recording is starting up but not yet 
       
  3300           // started, display toolbar when keylock is set off since we are 
       
  3301           // returning to precapture view, unless capturing is still going on.
       
  3302           if ( iView == iVideoCaptureView 
       
  3303               && iController.CurrentOperation() != ECamCapturing 
       
  3304               && !iController.IsProcessingCapture() )
       
  3305               {
       
  3306              if ( iController.IsTouchScreenSupported() )
       
  3307                  {
       
  3308                  CAknToolbar* toolbar = CurrentFixedToolbar();
       
  3309                  if ( toolbar )
       
  3310                       {
       
  3311                       toolbar->SetToolbarVisibility( ETrue );
       
  3312                       }
       
  3313                  }
       
  3314               }
       
  3315           break;
       
  3316           }
       
  3317         // -----------------------------------------------------
       
  3318         case EEventFocusLost:
       
  3319           {
       
  3320           PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: case EEventFocusLost") );
       
  3321 
       
  3322           //When go to background from video post caputure view, we need to hide the toolbar to avoid icons overlap
       
  3323           if( AppInBackground( EFalse )
       
  3324               && iViewState == ECamViewStatePostCapture
       
  3325               && iMode == ECamControllerVideo )
       
  3326               {
       
  3327               SubmergeToolbar();
       
  3328               }
       
  3329 
       
  3330           // focus lost event while videocall active and camera in standby,
       
  3331           // no notification to views
       
  3332           if ( iController.InVideocallOrRinging()
       
  3333             && ECamViewStateStandby == iViewState )
       
  3334             {
       
  3335             // We call the base class and return
       
  3336             CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3337             return;         	
       
  3338             }	
       
  3339             
       
  3340           NotifyViews( ECamAppEventFocusLost );
       
  3341           
       
  3342           if ( iController.UiConfigManagerPtr()
       
  3343                && iController.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
  3344           // Shut down the Sensor API object.
       
  3345           iController.UpdateSensorApiL(EFalse);
       
  3346 
       
  3347           if ( iController.UiConfigManagerPtr() && 
       
  3348                iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  3349               {
       
  3350         	  // If record location setting is on, stop location trail when losing focus
       
  3351         	  if ( AppInBackground( EFalse ) )
       
  3352         	      {
       
  3353         	      PRINT( _L("Camera: CCamAppUi::HandleWsEventL focus lost, stop location trail") )
       
  3354         	      iController.StopLocationTrail();
       
  3355         	      }
       
  3356               }
       
  3357 
       
  3358     #if !defined (__WINSCW__)
       
  3359           // relinquish capture keys
       
  3360           UnRegisterCaptureKeys();    
       
  3361           
       
  3362           RArray <TInt> halfCaptureKeys;
       
  3363           CleanupClosePushL( halfCaptureKeys );
       
  3364 
       
  3365           // now get half key press code to register
       
  3366           if ( iController.UiConfigManagerPtr() )
       
  3367               {
       
  3368               iController.UiConfigManagerPtr()->
       
  3369                           SupportedPrimaryCameraAutoFocusKeyL( halfCaptureKeys );
       
  3370               }
       
  3371           if ( halfCaptureKeys.Count() > 0 )
       
  3372               {
       
  3373               // Simulate key up event for the half-press key to make
       
  3374               // sure autofocus does not get stuck when we lose focus.
       
  3375               TKeyEvent key;
       
  3376               key.iRepeats = 0;
       
  3377               key.iCode = 0;
       
  3378               key.iScanCode = halfCaptureKeys[0];
       
  3379               key.iModifiers = 0;
       
  3380               iEikonEnv->SimulateKeyEventL( key, EEventKeyUp );        
       
  3381               }
       
  3382           CleanupStack::PopAndDestroy( &halfCaptureKeys );
       
  3383     #endif
       
  3384           break;
       
  3385           }
       
  3386         // -----------------------------------------------------
       
  3387         case KUidValueAknsSkinChangeEvent:
       
  3388           {
       
  3389           if ( iNaviProgressBarModel )
       
  3390               {
       
  3391               iNaviProgressBarModel->ReloadResourceDataL();
       
  3392               }
       
  3393           break;
       
  3394           }
       
  3395         case EEventPointer:
       
  3396             PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: EEventPointer") );
       
  3397             // restart idle timer every time screen is touched
       
  3398             iController.StartIdleTimer();
       
  3399             break;
       
  3400         // -----------------------------------------------------
       
  3401         default:
       
  3402           PRINT( _L("Camera <> CCamAppUi::HandleWsEventL: unhandled case") );
       
  3403           break;
       
  3404         // -----------------------------------------------------
       
  3405         }
       
  3406     
       
  3407       CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
  3408     }
       
  3409   PRINT( _L("Camera <= CCamAppUi::HandleWsEventL") );
       
  3410   }
       
  3411 
       
  3412 
       
  3413 // -----------------------------------------------------------------------------
       
  3414 // NotifyViews
       
  3415 // -----------------------------------------------------------------------------
       
  3416 //
       
  3417 void
       
  3418 CCamAppUi::NotifyViews( const TCamAppEvent& aEvent )
       
  3419   {
       
  3420   PRINT( _L("Camera => CCamAppUi::NotifyViews") );
       
  3421   TUid settingsPluginUid = KNullUid;
       
  3422   if ( iPlugin )
       
  3423      {
       
  3424      settingsPluginUid = iPlugin->Id();  
       
  3425      }
       
  3426 
       
  3427   for( TInt i = 0; i < iViews->Count(); i++ )
       
  3428     {
       
  3429     const TUid& uid( (*iViews)[i]->Id() );
       
  3430     PRINT2( _L("Camera <> View[%2d] uid[%3d]"), i, uid.iUid );
       
  3431 
       
  3432 
       
  3433        if (
       
  3434              KGSCamImageSettingsViewId != uid &&
       
  3435              KGSCamVideoSettingsViewId != uid &&
       
  3436              settingsPluginUid != uid &&
       
  3437              ECamViewIdViaPlayerPlayBack != uid.iUid ) 
       
  3438 
       
  3439               {
       
  3440                static_cast<CCamViewBase*>( (*iViews)[i] )->HandleAppEvent( aEvent );
       
  3441               }
       
  3442       }
       
  3443 
       
  3444   PRINT( _L("Camera <= CCamAppUi::NotifyViews") );
       
  3445   }
       
  3446 
       
  3447 // -----------------------------------------------------------------------------
       
  3448 // CCamAppUi::ConstructPreCaptureViewsL
       
  3449 // Construct the application views
       
  3450 // -----------------------------------------------------------------------------
       
  3451 //
       
  3452 void CCamAppUi::ConstructPreCaptureViewsL()
       
  3453     {
       
  3454     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_CONSTRUCTPRECAPTUREVIEWSL, "e_CCamAppUi_ConstructPreCaptureViewsL 1" );
       
  3455     PRINT( _L( "Camera => CCamAppUi::ConstructPreCaptureViewsL()" ) ); 
       
  3456     PERF_EVENT_START_L2( EPerfEventPreCaptureViewConstruction );
       
  3457 
       
  3458     // Initialize views
       
  3459     CCamStillPreCaptureView* stillView =
       
  3460         CCamStillPreCaptureView::NewLC( iController );
       
  3461     iStillCaptureView = stillView;
       
  3462 
       
  3463     AddViewL( stillView );
       
  3464     CleanupStack::Pop( stillView );
       
  3465     
       
  3466     PRINT( _L( "Camera => CCamAppUi::ConstructPreCaptureViewsL() still view complete" ) ); 
       
  3467 
       
  3468     CCamVideoPreCaptureView* videoView = CCamVideoPreCaptureView::NewLC( iController );
       
  3469     iVideoCaptureView = videoView;
       
  3470 
       
  3471     AddViewL( videoView );
       
  3472     CleanupStack::Pop( videoView );
       
  3473 
       
  3474 #if !( defined(__WINS__) || defined(__WINSCW__) )
       
  3475     // Get Central Repository key indicating if product uses volume keys 
       
  3476     // for zoom. Load the zoom pane orientation value from the Central 
       
  3477     // Repository
       
  3478     if( !iRepository )
       
  3479         {
       
  3480         iRepository = CRepository::NewL( KCRUidCameraappSettings );
       
  3481         }
       
  3482 
       
  3483     TInt val = 0;
       
  3484     TInt err = iRepository->Get( KCamCrZoomUsingVolumeKeys, val );
       
  3485 
       
  3486     // If there is an error then assume volume keys not used
       
  3487     if ( err )
       
  3488         {
       
  3489         iZoomUsingVolumeKeys = EFalse;
       
  3490         }
       
  3491     else 
       
  3492         {
       
  3493         iZoomUsingVolumeKeys = val;
       
  3494         }
       
  3495         
       
  3496     if( iZoomUsingVolumeKeys )
       
  3497         {
       
  3498         // Remote controller observe
       
  3499         delete iVolumeKeyObserver;
       
  3500         iVolumeKeyObserver = NULL;
       
  3501         iVolumeKeyObserver = CCamRemConObserver::NewL( *this );
       
  3502         }
       
  3503     
       
  3504 #else
       
  3505     iZoomUsingVolumeKeys = EFalse;   
       
  3506 #endif // !( defined(__WINS__) || defined(__WINSCW__) ) 
       
  3507 
       
  3508     PERF_EVENT_END_L2( EPerfEventPreCaptureViewConstruction );
       
  3509     PRINT( _L( "Camera <= CCamAppUi::ConstructPreCaptureViewsL()" ) ); 
       
  3510     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_CONSTRUCTPRECAPTUREVIEWSL, "e_CCamAppUi_ConstructPreCaptureViewsL 0" );
       
  3511     }
       
  3512 
       
  3513 // -----------------------------------------------------------------------------
       
  3514 // CCamAppUi::ConstructPostCaptureViewsL
       
  3515 // Construct the application views
       
  3516 // -----------------------------------------------------------------------------
       
  3517 //
       
  3518 void CCamAppUi::ConstructPostCaptureViewsL()
       
  3519     {
       
  3520     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_CONSTRUCTPOSTCAPTUREVIEWSL, "e_CCamAppUi_ConstructPostCaptureViewsL 1" );
       
  3521     PRINT( _L( "Camera => CCamAppUi::ConstructPostCaptureViewsL()" ) ); 
       
  3522     if ( iPostCaptureViewsConstructed )
       
  3523         {
       
  3524         PRINT( _L( "Camera <= CCamAppUi::ConstructPostCaptureViewsL(,)iPostCaptureViewsConstructed == ETrue" ) ); 
       
  3525         OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP2_CCAMAPPUI_CONSTRUCTPOSTCAPTUREVIEWSL, "e_CCamAppUi_ConstructPostCaptureViewsL 0" );
       
  3526         return;
       
  3527         }
       
  3528 
       
  3529     PERF_EVENT_START_L2( EPerfEventPostCaptureViewConstruction );
       
  3530     
       
  3531     ConstructPostCaptureViewIfRequiredL( ECamViewStatePostCapture,    
       
  3532                                          ECamControllerImage );
       
  3533     ConstructPostCaptureViewIfRequiredL( ECamViewStateBurstThumbnail, 
       
  3534                                          ECamControllerImage );
       
  3535     ConstructPostCaptureViewIfRequiredL( ECamViewStatePostCapture,    
       
  3536                                          ECamControllerVideo );
       
  3537     
       
  3538     iPostCaptureViewsConstructed = ETrue;
       
  3539     PERF_EVENT_END_L2( EPerfEventPostCaptureViewConstruction );
       
  3540     PRINT( _L( "Camera <= CCamAppUi::ConstructPostCaptureViewsL()" ) ); 
       
  3541     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_CONSTRUCTPOSTCAPTUREVIEWSL, "e_CCamAppUi_ConstructPostCaptureViewsL 0" );
       
  3542     }
       
  3543 
       
  3544 // -----------------------------------------------------------------------------
       
  3545 // CCamAppUi::ConstructViewIfRequiredL
       
  3546 // Construct the application views
       
  3547 // -----------------------------------------------------------------------------
       
  3548 //
       
  3549 void CCamAppUi::ConstructViewIfRequiredL()
       
  3550     {
       
  3551     PRINT( _L( "Camera => CCamAppUi::ConstructViewIfRequiredL()" ) ); 
       
  3552 
       
  3553   // Initialize views
       
  3554   CAknView* view( NULL );
       
  3555 
       
  3556   switch( iTargetViewState )
       
  3557     {
       
  3558     // -----------------------------------------------------
       
  3559     // Construct one of the postcapture views if needed
       
  3560     case ECamViewStateBurstThumbnail:
       
  3561     case ECamViewStatePostCapture:
       
  3562       {
       
  3563       ConstructPostCaptureViewIfRequiredL( iTargetViewState, iMode );
       
  3564       break;
       
  3565       }
       
  3566     // -----------------------------------------------------
       
  3567     // construct settings views if needed
       
  3568     case ECamViewStateSettings:
       
  3569       {
       
  3570       if( !iPlugin )
       
  3571         {
       
  3572         CCamGSInterface* plugin = CCamGSInterface::NewL( KCamGSPluginUid );
       
  3573         CleanupStack::PushL( plugin );
       
  3574         AddViewL( plugin ); // Transfer ownership to AppUi
       
  3575         CleanupStack::Pop( plugin );
       
  3576         iPlugin = plugin;        
       
  3577         }
       
  3578       break;
       
  3579       }
       
  3580     // -----------------------------------------------------
       
  3581     // construct user scene setup view if needed
       
  3582     case ECamViewStateUserSceneSetup:
       
  3583       {
       
  3584       if( !iUserSceneSetupViewConstructed )
       
  3585         {           
       
  3586         view = CCamStillUserSceneSetupView::NewLC( iController );
       
  3587         AddViewL( view );
       
  3588         CleanupStack::Pop( view );
       
  3589         iUserSceneSetupViewConstructed = ETrue;
       
  3590         }
       
  3591       break;
       
  3592       }
       
  3593     // -----------------------------------------------------
       
  3594  
       
  3595     default:
       
  3596       {
       
  3597       // no action
       
  3598       break;
       
  3599       }
       
  3600     // -----------------------------------------------------
       
  3601     }
       
  3602   PRINT( _L( "Camera <= CCamAppUi::ConstructViewIfRequiredL" ) ); 
       
  3603   }
       
  3604 
       
  3605 // -----------------------------------------------------------------------------
       
  3606 // CCamAppUi::ConstructNaviPaneL
       
  3607 // Construct the navi pane
       
  3608 // -----------------------------------------------------------------------------
       
  3609 //
       
  3610 void CCamAppUi::ConstructNaviPaneL()
       
  3611     {
       
  3612      OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_CONSTRUCTNAVIPANEL, "e_CCamAppUi_ConstructNaviPaneL 1" );
       
  3613      // Navi pane indicators
       
  3614     iNaviPaneCounterControl = 
       
  3615                             CCamNaviCounterControl::NewL( *iNaviCounterModel );
       
  3616     
       
  3617     iDecoratedNaviPaneCounter = 
       
  3618         CAknNavigationDecorator::NewL( NaviPaneL(), iNaviPaneCounterControl );   
       
  3619 
       
  3620     iDecoratedNaviPaneCounter->SetContainerWindowL( 
       
  3621             *(StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ) );   
       
  3622     iNaviPaneCounterControl->SetContainerWindowL( *iDecoratedNaviPaneCounter );
       
  3623 
       
  3624     iNaviPaneProgressBarControl = 
       
  3625                     CCamNaviProgressBarControl::NewL( *iNaviProgressBarModel );
       
  3626     
       
  3627     iDecoratedNaviPaneProgressBar = CAknNavigationDecorator::NewL( 
       
  3628                                     NaviPaneL(), iNaviPaneProgressBarControl );   
       
  3629 
       
  3630     iDecoratedNaviPaneProgressBar->SetContainerWindowL( 
       
  3631             *(StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ) );   
       
  3632     iNaviPaneProgressBarControl->SetContainerWindowL( 
       
  3633                                               *iDecoratedNaviPaneProgressBar );
       
  3634     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_CONSTRUCTNAVIPANEL, "e_CCamAppUi_ConstructNaviPaneL 0" );
       
  3635     }
       
  3636 
       
  3637 // ----------------------------------------------------
       
  3638 // CCamAppUi::DoPostCaptureTimeoutL
       
  3639 // Implementation function for post capture view timeout
       
  3640 // ----------------------------------------------------
       
  3641 //
       
  3642 TInt CCamAppUi::DoPostCaptureTimeoutL()
       
  3643     {
       
  3644     // If burst mode is active, switch to thumbnail view
       
  3645     if ( iViewState == ECamViewStatePostCapture &&
       
  3646          iImageMode == ECamImageCaptureBurst )
       
  3647         {
       
  3648         iTargetViewState = ECamViewStateBurstThumbnail ;
       
  3649         }
       
  3650     // otherwise, return to pre-capture view
       
  3651     else if (iCamOrientation == ECamOrientationPortrait) 
       
  3652       {
       
  3653       iTargetViewState = ECamViewStatePrePortraitCapture;
       
  3654       }
       
  3655     else
       
  3656       {
       
  3657       iTargetViewState = ECamViewStatePreCapture;   	
       
  3658       }
       
  3659     
       
  3660     TrySwitchViewL();
       
  3661     return EFalse;
       
  3662     }
       
  3663 
       
  3664 // ----------------------------------------------------
       
  3665 // CCamAppUi::TrySwitchViewL
       
  3666 // Try to switch active view
       
  3667 // ----------------------------------------------------
       
  3668 //
       
  3669 void 
       
  3670 CCamAppUi::TrySwitchViewL( TBool aDeactivateFirst )
       
  3671   {
       
  3672   PRINT2(_L("Camera => CCamAppUi::TrySwitchViewL, iTargetViewState = %d, iViewState = %d"), iTargetViewState, iViewState);
       
  3673   PRINT2(_L("Camera <> CCamAppUi::TrySwitchViewL, iTargetMode = %d, iMode = %d"), iTargetMode, iMode);
       
  3674   
       
  3675   //Sometimes current view and target view are same. For example switching from main camera to secondary camera
       
  3676   //always sets target mode to precaptrueview and current view could already be in precapture view. This is fine
       
  3677   //but In some postcaptureview cases current view and targetview is postcapture.
       
  3678   //In those cases view switching is not needed unless current mode also changes.
       
  3679   if( (iViewState==iTargetViewState) && ( iViewState==ECamViewStatePostCapture) && (iMode==iTargetMode) )
       
  3680       {
       
  3681       PRINT(_L("Camera <> CCamAppUi::TrySwitchViewL, CALLED WITHOUT PURPOSE"));      
       
  3682       return;
       
  3683       }  
       
  3684   
       
  3685   if( iZoomUsingVolumeKeys && !iVolumeKeyObserver &&
       
  3686       ECamViewStatePreCapture == iTargetViewState )
       
  3687     {
       
  3688     // Volumekeyobserver has been removed due to activating an external
       
  3689     // view. Volume keys are only needed for zooming in precapture, so we
       
  3690     // re-create the observer during next switch to precap (=now)  
       
  3691     iVolumeKeyObserver = CCamRemConObserver::NewL( *this );            
       
  3692     }
       
  3693    
       
  3694    
       
  3695     //if burst capture stopped for usb inserted, iTargetViewState is ECamViewStatePreCapture, it need to stop sequence capture too.
       
  3696     if ( iViewState == ECamViewStatePreCapture && 
       
  3697           ( iTargetViewState == ECamViewStateBurstThumbnail || 
       
  3698           ( ( iTargetViewState == ECamViewStatePreCapture ) && iController.IsCaptureStoppedForUsb() ) ) && 
       
  3699        iController.SequenceCaptureInProgress() )       
       
  3700 	{
       
  3701 	iController.StopSequenceCaptureL();	
       
  3702 	}
       
  3703 
       
  3704   // some views are only constructed when they are first used
       
  3705   TRAPD( err, ConstructViewIfRequiredL() )
       
  3706   PRINT1( _L( "Camera <> view constrcuction status:%d"), err )
       
  3707   // if the view construction failed
       
  3708   if ( err )
       
  3709     {
       
  3710     iTargetViewState = ECamViewStatePreCapture;
       
  3711     User::Leave( err );
       
  3712     } 
       
  3713 
       
  3714   // if the application is in the background the view switch will happen 
       
  3715   // when we get the foreground again. This stops the app coming back to
       
  3716   // the foreground when the view switch occurs.
       
  3717   // If keylock is enabled, view switching is allowed in order to avoid 
       
  3718   // flickering
       
  3719   
       
  3720   if ( AppInBackground( ETrue ) && ECamViewStateStandby != iTargetViewState )  
       
  3721     {          
       
  3722     PRINT( _L("Camera <> app in background set pending view switch") )
       
  3723     if ( aDeactivateFirst )
       
  3724       {
       
  3725       PRINT( _L("Camera <> setting iPendingViewSwitch = EPendingViewSwitchDeactivateFirst") )
       
  3726       iPendingViewSwitch = EPendingViewSwitchDeactivateFirst;
       
  3727       }
       
  3728     else
       
  3729       {
       
  3730       // If a deactivate first view switch has already been requested 
       
  3731       // then don't overwrite it
       
  3732       if ( iPendingViewSwitch != EPendingViewSwitchDeactivateFirst )
       
  3733         {
       
  3734         PRINT( _L("Camera <> setting iPendingViewSwitch = EPendingViewSwitchNormal") )
       
  3735         iPendingViewSwitch = EPendingViewSwitchNormal;
       
  3736         }
       
  3737       }
       
  3738     PRINT( _L("Camera TrySwitchViewL returning without switch") );
       
  3739     return;
       
  3740     }
       
  3741   
       
  3742   if ( iController.UiConfigManagerPtr() && 
       
  3743        iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() &&
       
  3744        !iUiConstructionComplete )
       
  3745     {
       
  3746     iPendingViewSwitch = EPendingViewSwitchNormal;
       
  3747     PRINT( _L("Camera <= CCamAppUi::TrySwitchViewL setting EPendingViewSwitchNormal, return") );
       
  3748     return;   
       
  3749     }
       
  3750 
       
  3751   TCamViewSwitch switchNeeded = ViewSwitchRequired( aDeactivateFirst );
       
  3752   PRINT( _L("Camera TrySwitchViewL C") )
       
  3753   if ( iTargetViewState == ECamViewStatePreCapture )
       
  3754     {
       
  3755     PRINT( _L("Camera TrySwitchViewL D") )
       
  3756     // if going back to precapture view in timelapse mode then the array
       
  3757     // of timelapse filenames can now be deleted
       
  3758     if ( iImageMode == ECamImageCaptureTimeLapse )
       
  3759       {
       
  3760       iController.ResetTimelapseArray();
       
  3761       }        
       
  3762    
       
  3763     // If exiting a post capture view, release the capture array
       
  3764     if ( iViewState == ECamViewStatePostCapture ) 
       
  3765       {
       
  3766       iController.ReleaseArray();
       
  3767       }
       
  3768     else if( iViewState == ECamViewStateBurstThumbnail )
       
  3769       {
       
  3770       iController.ReleaseArray( ETrue );    
       
  3771       }
       
  3772     if ( iPreCaptureMode != ECamPreCapTimeLapseSlider )
       
  3773       {
       
  3774       iPreCaptureMode = ECamPreCapViewfinder;
       
  3775       }       
       
  3776     }
       
  3777 
       
  3778   if ( iTargetViewState == ECamViewStatePostCapture )
       
  3779     {
       
  3780     // If going to post capture, make sure the AP is displayed
       
  3781     iPreventActivePaletteDisplay = EFalse;
       
  3782     }
       
  3783 
       
  3784   // If no switches are required
       
  3785   if ( switchNeeded == ECamViewSwitchNone )
       
  3786     {
       
  3787     PRINT( _L("Camera TrySwitchViewL no VS") )
       
  3788     if ( IsDirectViewfinderActive() )
       
  3789       {
       
  3790       TRAP_IGNORE(HandleCommandL( ECamCmdRedrawScreen ));
       
  3791       }
       
  3792     return;
       
  3793     }
       
  3794   // If a full view switch is required, activate new view
       
  3795   if ( switchNeeded == ECamViewSwitch )
       
  3796     {
       
  3797     PRINT( _L("Camera <> CCamAppUi::TrySwitchViewL: Stop VF for full view switch") )
       
  3798     // this skip VF stopping if DV is active and camera is in standby mode
       
  3799     // possible if screensaver delay is short and startup takes long enough
       
  3800     if ( ECamViewStateStandby == iViewState && 
       
  3801     // DSVF active or in bitmap mode in any active camera (no need to stop VF)
       
  3802           ( IsDirectViewfinderActive() || 
       
  3803             ( ECamActiveCameraSecondary == ActiveCamera() && 
       
  3804               !iController.UiConfigManagerPtr()->IsDSAViewFinderSupported( EFalse ) ) ||      
       
  3805             ( ECamActiveCameraPrimary == ActiveCamera() && 
       
  3806               !iController.UiConfigManagerPtr()->IsDSAViewFinderSupported( ETrue ) ) ) )    
       
  3807       {
       
  3808       PRINT( _L("Camera <> CCamAppUi::TrySwitchViewL: !!! No stopviewfinder in Standby !!!") )	
       
  3809       }
       
  3810     else
       
  3811       {
       
  3812       SetViewFinderInTransit(ETrue);
       
  3813       iController.StopViewFinder();
       
  3814       TUid viewId = iView->Id();
       
  3815       if(viewId == TUid::Uid( ECamViewIdStillPreCapture )
       
  3816           || viewId == TUid::Uid( ECamViewIdVideoPreCapture ))
       
  3817           {
       
  3818           CCamViewBase* view = static_cast<CCamViewBase*>(iView);
       
  3819           CCamContainerBase* container = view->Container(); 
       
  3820           container->DrawNow();
       
  3821           }
       
  3822       
       
  3823       }
       
  3824     PRINT( _L("Camera TrySwitchViewL E") )
       
  3825     TUid uid;
       
  3826     TUid messageUid;
       
  3827     TBool validView = ViewId( iTargetViewState, 
       
  3828                               iTargetMode, 
       
  3829                               iTargetImageMode, 
       
  3830                               uid, 
       
  3831                               messageUid, 
       
  3832                               aDeactivateFirst );
       
  3833     PRINT2(_L("Camera <> CCamAppUi::TrySwitchViewL, iTargetViewState = %d, iViewState = %d"), 
       
  3834                                                     iTargetViewState, iViewState);
       
  3835     PRINT2(_L("Camera <> CCamAppUi::TrySwitchViewL, uid = %d, messageUid = %d"), 
       
  3836                                                     uid.iUid, messageUid.iUid);  
       
  3837     
       
  3838     __ASSERT_DEBUG( validView, CamPanic( ECamPanicInvalidView ) );
       
  3839 
       
  3840     if ( validView )  
       
  3841         {
       
  3842         PRINT( _L("Camera TrySwitchViewL f") )
       
  3843         // the cba is reset when the view is activated
       
  3844         iCbaIsDisabled = EFalse;
       
  3845         ActivateLocalViewL( uid, messageUid, KNullDesC8 );
       
  3846         // If self timer mode is enabled and we are switching views, we need to 
       
  3847         // disable Self Timer
       
  3848         if ( iInSelfTimerMode != ECamSelfTimerDisabled)
       
  3849             {
       
  3850             SelfTimerEnableL( ECamSelfTimerDisabled );
       
  3851             }
       
  3852         }
       
  3853     }
       
  3854     
       
  3855   // Mode only switches are handled here
       
  3856 
       
  3857   // ...if we are switching to/from the video/photo views then
       
  3858   // ...reset the dynamic settings.
       
  3859   if ( (  ( iMode != ECamControllerVideo ) && 
       
  3860           ( iTargetMode == ECamControllerVideo ) )
       
  3861       ||
       
  3862       (   ( iMode == ECamControllerVideo ) && 
       
  3863           ( iTargetMode != ECamControllerVideo ) ) )
       
  3864     {
       
  3865 #ifdef RESET_DYNAMIC_SETTINGS_WHEN_SWITCH_MODE
       
  3866     iController.SetDynamicSettingsToDefaults();
       
  3867 #endif // RESET_DYNAMIC_SETTINGS_WHEN_SWITCH_MODE
       
  3868     }
       
  3869 
       
  3870   if ( iController.UiConfigManagerPtr() && iDSASupported )
       
  3871     {
       
  3872       // ...check if we are moving to BurstCapture
       
  3873       // 
       
  3874       if ( // If entering burst mode...
       
  3875           ( ( iTargetImageMode == ECamImageCaptureBurst     ||
       
  3876               iTargetImageMode == ECamImageCaptureTimeLapse ) &&
       
  3877               iImageMode       == ECamImageCaptureSingle )
       
  3878              // ...or leaving burst mode
       
  3879            || 
       
  3880             ( ( iImageMode       == ECamImageCaptureBurst     || 
       
  3881                 iImageMode       == ECamImageCaptureTimeLapse ) &&     
       
  3882                 iTargetImageMode == ECamImageCaptureSingle )
       
  3883            )     
       
  3884         {
       
  3885         // Stop the viewfinder (using the current state)
       
  3886         PRINT( _L("Camera TrySwitchViewL burst stop VF") )
       
  3887         iController.StopViewFinder();
       
  3888         
       
  3889         // Update AppUi internal state 
       
  3890         iViewState = iTargetViewState;
       
  3891         iMode      = iTargetMode;
       
  3892         iImageMode = iTargetImageMode;
       
  3893         
       
  3894         }
       
  3895       else        
       
  3896         {
       
  3897         // Not entering/leaving burst mode, so just update the state 
       
  3898         iViewState = iTargetViewState;
       
  3899         iMode      = iTargetMode;          
       
  3900         iImageMode = iTargetImageMode;
       
  3901         }
       
  3902     }
       
  3903   else
       
  3904     {
       
  3905       // ...set the current capture mode and view state to the targets.
       
  3906       iViewState = iTargetViewState;
       
  3907       iMode      = iTargetMode;  
       
  3908       iImageMode = iTargetImageMode;
       
  3909     }
       
  3910 
       
  3911   PRINT(_L("Camera <= CCamAppUi::TrySwitchViewL"));
       
  3912   }
       
  3913 
       
  3914 // ----------------------------------------------------
       
  3915 // CCamAppUi::ViewSwitchRequired
       
  3916 // Is a switch of the active view necessary
       
  3917 // ----------------------------------------------------
       
  3918 //
       
  3919 
       
  3920 CCamAppUi::TCamViewSwitch 
       
  3921 CCamAppUi::ViewSwitchRequired( TBool aDeactivateFirst ) const
       
  3922   {   
       
  3923   CCamAppUi::TCamViewSwitch vSwitch = ECamViewSwitchNone;
       
  3924 
       
  3925   if ( aDeactivateFirst )
       
  3926     {
       
  3927     // View switch required
       
  3928     vSwitch = ECamViewSwitch;
       
  3929     }
       
  3930   else
       
  3931     {
       
  3932     // Post <=> Pre and/or Video <=> Image always require view switch
       
  3933     if ( iTargetViewState == iViewState 
       
  3934       && iTargetMode      == iMode )
       
  3935       {
       
  3936       // single / burst / timelapse
       
  3937       if( iTargetImageMode == iImageMode )
       
  3938         {
       
  3939         // Completely same mode already
       
  3940         vSwitch = ECamViewSwitchNone;
       
  3941         }
       
  3942       else  
       
  3943         {
       
  3944         // No view switch is required for changing between these modes
       
  3945         vSwitch = ECamViewSwitchModeOnly;
       
  3946         }
       
  3947       }
       
  3948     else
       
  3949       {
       
  3950       // View switch required 
       
  3951       vSwitch = ECamViewSwitch;
       
  3952       }
       
  3953     }
       
  3954 
       
  3955   return vSwitch;
       
  3956   }
       
  3957 
       
  3958 // ----------------------------------------------------
       
  3959 // CCamAppUi::ViewId
       
  3960 // Get uid of view with requested state and mode
       
  3961 // ----------------------------------------------------
       
  3962 //
       
  3963 TBool CCamAppUi::ViewId( TCamViewState        aState, 
       
  3964                          TCamCameraMode       aMode, 
       
  3965                          TCamImageCaptureMode aImageMode, 
       
  3966                          TUid&                aUid, 
       
  3967                          TUid&                aMessageUid,
       
  3968                          TBool                aDeactivateFirst )
       
  3969   {
       
  3970   aMessageUid.iUid = 0;
       
  3971   
       
  3972   TBool found = EFalse;
       
  3973   switch ( aState )
       
  3974     {       
       
  3975     // -----------------------------------------------------
       
  3976     case ECamViewStateStandby:
       
  3977       {
       
  3978       // Custom message to pass to the view, is to initiate standby
       
  3979       aMessageUid.iUid = ECamViewMessageStandby;
       
  3980       }
       
  3981     //lint -fallthrough 
       
  3982     // -----------------------------------------------------
       
  3983     case ECamViewStatePreCapture: // fallthrough
       
  3984       {
       
  3985       if ( aDeactivateFirst )
       
  3986         {
       
  3987         aMessageUid.iUid = ECamViewMessageDeactivateFirst;
       
  3988         }
       
  3989       if ( aMode == ECamControllerVideo )
       
  3990         {
       
  3991         aUid.iUid = ECamViewIdVideoPreCapture;               
       
  3992         }
       
  3993       else 
       
  3994         {
       
  3995         aUid.iUid = ECamViewIdStillPreCapture;
       
  3996         }
       
  3997       found = ETrue;
       
  3998       break;
       
  3999       }
       
  4000     // -----------------------------------------------------
       
  4001     case ECamViewStateSceneSettingList:
       
  4002       {
       
  4003       // Ensure the view starts with the capture setup menu displayed.
       
  4004       aMessageUid.iUid = ECamViewMessageSceneSettingList;
       
  4005       if ( aMode == ECamControllerVideo )
       
  4006         {
       
  4007         aUid.iUid = ECamViewIdVideoPreCapture;
       
  4008         }
       
  4009       else 
       
  4010         {
       
  4011         aUid.iUid = ECamViewIdStillPreCapture;
       
  4012         }
       
  4013       found = ETrue;
       
  4014       break;
       
  4015       }
       
  4016     // -----------------------------------------------------
       
  4017     case ECamViewStatePostCapture:
       
  4018       {
       
  4019       if ( aMode == ECamControllerVideo )
       
  4020         {
       
  4021         aUid.iUid = ECamViewIdVideoPostCapture;
       
  4022         }
       
  4023       else 
       
  4024         {
       
  4025         aUid.iUid = ECamViewIdStillPostCapture;
       
  4026         }
       
  4027       found = ETrue;
       
  4028       break;
       
  4029       }
       
  4030     // -----------------------------------------------------
       
  4031     case ECamViewStateBurstThumbnail:
       
  4032       {
       
  4033       if ( ECamControllerImage   == aMode
       
  4034         && ECamImageCaptureBurst == aImageMode )
       
  4035         {
       
  4036         aUid.iUid = ECamViewIdBurstThumbnail;
       
  4037         // We have view id for multi capture mode
       
  4038         found = ETrue;
       
  4039         }
       
  4040       else
       
  4041         {
       
  4042         // No valid view id
       
  4043         found = EFalse;
       
  4044         }
       
  4045       break;
       
  4046       }
       
  4047     // -----------------------------------------------------
       
  4048     case ECamViewStateSettings:
       
  4049       {
       
  4050       TUid viewUid = KNullUid;
       
  4051       aMessageUid = KNullUid;
       
  4052  
       
  4053       if ( ECamControllerVideo == aMode )
       
  4054           {
       
  4055           if ( IsSecondCameraEnabled() )
       
  4056               {
       
  4057               aMessageUid = TUid::Uid( KGSSecondaryCameraVideoSettingsView );
       
  4058               }
       
  4059           viewUid = KGSCamVideoSettingsViewId;
       
  4060           }
       
  4061       else
       
  4062           { 
       
  4063           if ( IsSecondCameraEnabled() )
       
  4064               {
       
  4065               aMessageUid = TUid::Uid( KGSSecondaryCameraPhotoSettingsView );
       
  4066               }
       
  4067           viewUid = KGSCamImageSettingsViewId;
       
  4068           }
       
  4069       
       
  4070       if ( iPlugin )
       
  4071           {
       
  4072           aUid = viewUid;
       
  4073           found = ETrue;	
       
  4074           }
       
  4075 
       
  4076       break;
       
  4077       }
       
  4078     // -----------------------------------------------------
       
  4079     case ECamViewStateUserSceneSetup:
       
  4080       {
       
  4081       if ( aMode != ECamControllerVideo )
       
  4082         {
       
  4083         aUid.iUid = ECamViewIdPhotoUserSceneSetup;
       
  4084         // We have a photo user scene setup view id
       
  4085         found = ETrue;
       
  4086         }
       
  4087       else
       
  4088         {
       
  4089         found = EFalse;
       
  4090         }           
       
  4091       break;
       
  4092       }
       
  4093     // -----------------------------------------------------
       
  4094     default:                    
       
  4095       break;
       
  4096     // -----------------------------------------------------
       
  4097     }
       
  4098 
       
  4099   return found;
       
  4100   }
       
  4101 
       
  4102 // ----------------------------------------------------
       
  4103 // CCamAppUi::NaviPaneL
       
  4104 // Return a pointer to the status pane's navi control container
       
  4105 // ----------------------------------------------------
       
  4106 //
       
  4107 CAknNavigationControlContainer* CCamAppUi::NaviPaneL()
       
  4108     {
       
  4109     return static_cast<CAknNavigationControlContainer*>(
       
  4110                 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  4111     }
       
  4112 
       
  4113 // ---------------------------------------------------------------------------
       
  4114 // CCamAppUi::UpdateCba
       
  4115 // Update softkeys to reflect current state
       
  4116 // ---------------------------------------------------------------------------
       
  4117 //
       
  4118 void CCamAppUi::UpdateCba()
       
  4119     {    
       
  4120     CCamViewBase* view = static_cast<CCamViewBase*>( iView );        
       
  4121     TRAP_IGNORE( view->UpdateCbaL() );             
       
  4122     }
       
  4123 
       
  4124 // Added back, but modified the note string resource
       
  4125 // ----------------------------------------------------
       
  4126 // CCamAppUi::DisplayWaitDialogL
       
  4127 // Displays the wait dialog when saving video
       
  4128 // ----------------------------------------------------
       
  4129 //
       
  4130 void CCamAppUi::DisplayWaitDialogL()
       
  4131     {
       
  4132 //    __ASSERT_DEBUG( iWaitDialog == NULL, CamPanic( ECamPanicUi ) );
       
  4133     if ( iWaitDialog == NULL )
       
  4134        {
       
  4135         // Display saving video wait note
       
  4136         // The wait note has its initial delay disabled. This is because the call
       
  4137         // to the engine to stop recording does not return until the video save 
       
  4138         // etc. has completed. This does not give the wait dialog a chance to 
       
  4139         // receive its timer call back and display itself. 
       
  4140         iWaitDialog = new( ELeave ) CCamWaitDialog(
       
  4141                 reinterpret_cast<CEikDialog**>( &iWaitDialog ), ETrue );
       
  4142         iWaitDialog->ExecuteLD( R_CAM_SAVING_VIDEO_WAIT_NOTE );
       
  4143         // From base class CEikDialog to prevent S60 style CBAs from showing 
       
  4144         // unnecessarily
       
  4145         iWaitDialog->ButtonGroupContainer().MakeVisible(EFalse);
       
  4146        }
       
  4147     }
       
  4148 
       
  4149 
       
  4150 // ---------------------------------------------------------
       
  4151 // CCamAppUi::StartupMode
       
  4152 // Get startup capture mode from settings
       
  4153 // ---------------------------------------------------------
       
  4154 //
       
  4155 TCamStartupMode CCamAppUi::StartupMode() const
       
  4156   {    
       
  4157   __ASSERT_DEBUG( iRepository, CamPanic( ECamPanicNullPointer ) );
       
  4158 
       
  4159   TInt value = 0;
       
  4160   TInt err = iRepository->Get( KCamCrDefaultCaptureMode, value );
       
  4161   TCamStartupMode setting = static_cast<TCamStartupMode>( value );
       
  4162   if ( err == KErrAbort ||
       
  4163        err == KErrPermissionDenied ||
       
  4164        err == KErrNotFound ||
       
  4165        err == KErrArgument )
       
  4166     {
       
  4167     PRINT1( _L("Camera <> CCamAppUi::StartupMode err=%d"), err );
       
  4168     CamPanic( ECamPanicDefaultNotFoundInIniFile );      
       
  4169     }
       
  4170 
       
  4171   return setting;
       
  4172   }
       
  4173 
       
  4174 // ---------------------------------------------------------
       
  4175 // CCamAppUi::SaveCaptureMode
       
  4176 // Save current capture mode to settings
       
  4177 // ---------------------------------------------------------
       
  4178 //
       
  4179 void CCamAppUi::SaveCaptureMode()
       
  4180     { 
       
  4181     // Since this function can be called from the destructor, it is neccesary 
       
  4182     // to check that iRepository is not null prior to use
       
  4183     if ( iRepository && !IsEmbedded() )    
       
  4184         {
       
  4185         switch ( iMode )         
       
  4186             {
       
  4187             case ECamControllerImage:
       
  4188                 // Ignore errors
       
  4189                 iRepository->Set( KCamCrDefaultCaptureMode, ECamStillCapture );
       
  4190                 break;
       
  4191             case ECamControllerVideo:
       
  4192                 // Ignore errors
       
  4193                 iRepository->Set( KCamCrDefaultCaptureMode, ECamVideoCapture );
       
  4194                 break;
       
  4195             default:
       
  4196                break;            
       
  4197             }
       
  4198         }
       
  4199     }
       
  4200 
       
  4201 
       
  4202 // ---------------------------------------------------------
       
  4203 // CCamAppUi::SaveCourtesyUiState
       
  4204 // Save whether or not the UI should always be drawn.
       
  4205 // ---------------------------------------------------------
       
  4206 //
       
  4207 
       
  4208 void CCamAppUi::SaveCourtesyUiState()
       
  4209   {
       
  4210   // Since this function can be called from the destructor, 
       
  4211   // it is neccesary to check that iRepository is not null prior to use    
       
  4212   if ( iRepository )
       
  4213     {
       
  4214     iRepository->Set( KCamCrAlwaysDrawCourtesyUi, 
       
  4215                       iAlwaysDrawPreCaptureCourtesyUI );
       
  4216     }
       
  4217   }
       
  4218 
       
  4219 
       
  4220 
       
  4221 // ---------------------------------------------------------
       
  4222 // CCamAppUi::InitCaptureCountL
       
  4223 // Sets up the number of images to be captured
       
  4224 // ---------------------------------------------------------
       
  4225 //
       
  4226 void CCamAppUi::InitCaptureCountL()
       
  4227     {
       
  4228     PRINT( _L("Camera => CCamAppUi::InitCaptureCountL" ))
       
  4229     // If video mode is active, capture count is not used
       
  4230     if ( iMode == ECamControllerImage )
       
  4231         {
       
  4232         TInt imageCount = 1;
       
  4233 
       
  4234         switch( iImageMode )
       
  4235             {
       
  4236             case ECamImageCaptureBurst:
       
  4237                 // Capture count initially set to 6 for short burst.
       
  4238                 // Once long burst is determined we adjust the burst count.
       
  4239                 // This approach keeps short burst as fast as possible.
       
  4240                 imageCount = KShortBurstCount;
       
  4241                 break;
       
  4242             case ECamImageCaptureTimeLapse:
       
  4243                 // In timelapse mode set the limit as high as possible,
       
  4244                 // unless self-timer is used. In that case only 6 images
       
  4245                 // will be captured.
       
  4246                 if ( ECamSelfTimerDisabled != iInSelfTimerMode )
       
  4247                     {
       
  4248                     imageCount = KShortBurstCount;
       
  4249                     }
       
  4250                 else
       
  4251                     {
       
  4252                     imageCount = iMaxBurstCaptureNum;
       
  4253                     }
       
  4254                 break;
       
  4255             default:
       
  4256                 // Single capture mode. Keep 1 as limit.
       
  4257                 break;
       
  4258             }
       
  4259 
       
  4260         iController.SetCaptureLimitL( imageCount );
       
  4261         }
       
  4262     PRINT( _L("Camera <= CCamAppUi::InitCaptureCountL" ))  
       
  4263     }
       
  4264 
       
  4265 // ---------------------------------------------------------
       
  4266 // CCamAppUi::SetCaptureMode
       
  4267 // Set the current capture mode
       
  4268 // ---------------------------------------------------------
       
  4269 //
       
  4270 void 
       
  4271 CCamAppUi::SetCaptureMode( TCamCameraMode       aMode, 
       
  4272                            TCamImageCaptureMode aImageMode /*= ECamImageCaptureNone*/)
       
  4273     {
       
  4274     iMode = aMode;
       
  4275     iImageMode = aImageMode;
       
  4276     iTargetMode = aMode;
       
  4277     iTargetImageMode = aImageMode;
       
  4278     }
       
  4279 
       
  4280 // ---------------------------------------------------------
       
  4281 // CCamAppUi::SetTitleEmbeddedL
       
  4282 // Set title to  the name of embedding application
       
  4283 // ---------------------------------------------------------
       
  4284 //
       
  4285 void CCamAppUi::SetTitleEmbeddedL()
       
  4286     {
       
  4287     if (iParentAppName != NULL )
       
  4288         {
       
  4289         SetTitleL ( *iParentAppName );
       
  4290         }
       
  4291     }
       
  4292 
       
  4293 // ---------------------------------------------------------
       
  4294 // CCamAppUi::CheckMemoryL
       
  4295 // Checks if there is sufficient space available for capture
       
  4296 // ---------------------------------------------------------
       
  4297 //
       
  4298 TBool 
       
  4299 CCamAppUi::CheckMemoryL()
       
  4300     {
       
  4301     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_CHECKMEMORYL, 
       
  4302     			"e_CCamAppUi_CheckMemoryL 1" );
       
  4303     PRINT( _L("Camera => CCamAppUi::CheckMemoryL") );
       
  4304     TBool capture = ETrue;
       
  4305 
       
  4306    TCamMediaStorage  storeToCheck = ECamMediaStorageCurrent;
       
  4307 
       
  4308    if ( ECamControllerVideo == iController.CurrentMode() &&
       
  4309         ECamMediaStorageCard == iController.IntegerSettingValue( ECamSettingItemVideoMediaStorage ) &&
       
  4310         IsMemoryFullOrUnavailable( ECamMediaStorageCard ) )
       
  4311     	{
       
  4312     	storeToCheck =  ECamMediaStorageCard; 
       
  4313     	}
       
  4314     if(AllMemoriesFullOrUnavailable())
       
  4315     	{
       
  4316     	HBufC* text = StringLoader::LoadLC(R_NOTE_TEXT_ALLMEMORY_FULL);
       
  4317     	TInt ret = ShowOOMNoteL( *text, EFalse);
       
  4318     	capture = EFalse;
       
  4319     	CleanupStack::PopAndDestroy(text);
       
  4320     	}
       
  4321     else if(IsMemoryFullOrUnavailable( storeToCheck ))
       
  4322 		{
       
  4323 		HBufC* text = StringLoader::LoadLC(R_NOTE_TEXT_MEMORY_FULL);
       
  4324 		CAknStaticNoteDialog* note = new( ELeave ) CAknStaticNoteDialog;
       
  4325 		note->PrepareLC( R_CAM_OOM_NOTE_OK_CANCEL);
       
  4326 		note->SetTextL( *text );
       
  4327 		iController.StopIdleTimer();
       
  4328 		TInt ret = note->RunDlgLD();
       
  4329 		CleanupStack::PopAndDestroy( text );
       
  4330 		if(EAknSoftkeyOk == ret)
       
  4331 			{
       
  4332 			//when memoryDialog showed, redraw background
       
  4333 			if ( IsDirectViewfinderActive() )
       
  4334 			  {
       
  4335 			  TRAP_IGNORE( HandleCommandL( ECamCmdRedrawScreen ) );
       
  4336 			  }
       
  4337       
       
  4338 			TInt supportedMemTypes = 0;
       
  4339 			TCamMediaStorage currentLocation;
       
  4340 			TInt key = ( ECamControllerVideo == iMode )
       
  4341 			? ECamSettingItemVideoMediaStorage
       
  4342 					: ECamSettingItemPhotoMediaStorage;
       
  4343 
       
  4344 			if ( iMMCRemoveNoteRequiredOnCapture )
       
  4345 				{
       
  4346 				iMMCRemoveNoteRequiredOnCapture = EFalse;
       
  4347 				currentLocation = static_cast<TCamMediaStorage>( 
       
  4348 									iController.
       
  4349 										IntegerSettingValueUnfiltered( key ) );
       
  4350 				}
       
  4351 			else
       
  4352 				{
       
  4353 				currentLocation = static_cast<TCamMediaStorage>( 
       
  4354 									iController.IntegerSettingValue( key ) );
       
  4355 				}
       
  4356 			if(currentLocation != ECamMediaStoragePhone && 
       
  4357 				!IsMemoryFullOrUnavailable(ECamMediaStoragePhone))
       
  4358 				{
       
  4359 				supportedMemTypes |= AknCommonDialogsDynMem::EMemoryTypePhone;
       
  4360 				}
       
  4361 			if(currentLocation != ECamMediaStorageCard && 
       
  4362 				!IsMemoryFullOrUnavailable(ECamMediaStorageCard))
       
  4363 				{
       
  4364 				supportedMemTypes |= AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
       
  4365 				}
       
  4366 			if(currentLocation != ECamMediaStorageMassStorage && 
       
  4367 				!IsMemoryFullOrUnavailable(ECamMediaStorageMassStorage))
       
  4368 				{
       
  4369 				supportedMemTypes |= 
       
  4370 						AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage;
       
  4371 				}
       
  4372 			
       
  4373 			CAknMemorySelectionDialogMultiDrive* memoryDialog = 
       
  4374 							CAknMemorySelectionDialogMultiDrive::NewL(
       
  4375 											   ECFDDialogTypeSelect,
       
  4376 											   R_CAM_MEMORY_SELECT_DIALOG,
       
  4377 											   EFalse,
       
  4378 											   supportedMemTypes );
       
  4379 			TDriveNumber driveNumber = static_cast<TDriveNumber>(KErrNotFound);    
       
  4380 			CAknCommonDialogsBase::TReturnKey result = 
       
  4381 								memoryDialog->ExecuteL( driveNumber );
       
  4382 			 		 
       
  4383 			if ( result != CAknCommonDialogsBase::TReturnKey(
       
  4384 								CAknCommonDialogsBase::ERightSoftkey) )
       
  4385 				 {
       
  4386 				 DriveInfo::TDefaultDrives memVal = 
       
  4387 				 	static_cast<DriveInfo::TDefaultDrives>(
       
  4388 				 		CamUtility::GetDriveTypeFromDriveNumber(driveNumber));
       
  4389 				 TInt settingValue = 
       
  4390 				 	CamUtility::MapFromSettingsListMemory( memVal );
       
  4391 				 iController.SetIntegerSettingValueL(key,settingValue);
       
  4392 				 }
       
  4393 			else
       
  4394 				{
       
  4395 				//No impl.
       
  4396 				}
       
  4397 			capture = EFalse;
       
  4398 			}
       
  4399     	else
       
  4400     		{
       
  4401     		capture = EFalse;
       
  4402     		}
       
  4403 		iController.StartIdleTimer();
       
  4404 		}
       
  4405     
       
  4406     PRINT1( _L("Camera <= CCamAppUi::CheckMemoryL, capture ok: %d"), capture );
       
  4407     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_CHECKMEMORYL, 
       
  4408     			"e_CCamAppUi_CheckMemoryL 0" );
       
  4409     return capture;
       
  4410     }
       
  4411 
       
  4412 // ---------------------------------------------------------
       
  4413 // CCamAppUi::ShowErrorNoteL
       
  4414 // Display error note
       
  4415 // ---------------------------------------------------------
       
  4416 //
       
  4417 void 
       
  4418 CCamAppUi::ShowErrorNoteL( TCamMemoryStatus aStatus )
       
  4419     {
       
  4420     PRINT( _L("Camera => CCamAppUi::ShowErrorNoteL") );
       
  4421     TInt resourceId;
       
  4422 
       
  4423     TCamMediaStorage currentLocation;
       
  4424     if ( iMode == ECamControllerVideo )
       
  4425         {
       
  4426         currentLocation = static_cast<TCamMediaStorage> 
       
  4427                     ( iController.IntegerSettingValueUnfiltered( ECamSettingItemVideoMediaStorage ) );
       
  4428         }
       
  4429     else // photo or burst mode
       
  4430         {
       
  4431         currentLocation = static_cast<TCamMediaStorage> 
       
  4432                     ( iController.IntegerSettingValueUnfiltered( ECamSettingItemPhotoMediaStorage ) );
       
  4433         }
       
  4434     TInt NumberOfParameters = 0;
       
  4435     TInt drive;
       
  4436     TFileName path;
       
  4437     TInt DriveError = KErrNone;
       
  4438 
       
  4439     // load text from resource
       
  4440     switch ( aStatus )
       
  4441         {
       
  4442         case ECamMemoryStatusMassStorageFull:
       
  4443             {
       
  4444             // internal and card both full
       
  4445             resourceId = R_NOTE_TEXT_MASSMEMORY_FULL;
       
  4446             // Get the root path of the memory.
       
  4447             DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive );
       
  4448             DriveError = PathInfo::GetRootPath( path, drive );
       
  4449             if ( DriveError == KErrNone )
       
  4450                 {
       
  4451                 // %U  parameter
       
  4452                 NumberOfParameters = 1;
       
  4453                 }
       
  4454             else 
       
  4455                 {
       
  4456                 // no %U  parameter
       
  4457                 NumberOfParameters = 0;
       
  4458                 }
       
  4459             }
       
  4460             break;
       
  4461 
       
  4462         case ECamMemoryStatusFull:
       
  4463             {
       
  4464             if ( currentLocation == ECamMediaStorageMassStorage ) 
       
  4465                 {
       
  4466                 // internal mass storage full
       
  4467                 resourceId = R_NOTE_TEXT_MASSMEMORY_FULL;
       
  4468                 // Get the root path of the memory.
       
  4469                 DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive );
       
  4470                 DriveError = PathInfo::GetRootPath( path, drive );
       
  4471                 }
       
  4472             else if ( currentLocation == ECamMediaStoragePhone )
       
  4473                 {
       
  4474                 // internal phone memory full
       
  4475                 resourceId = R_NOTE_TEXT_NOT_ENOUGH_DEVICE_MEMORY;
       
  4476                 // Get the root path of the memory.
       
  4477                 DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive );
       
  4478                 DriveError = PathInfo::GetRootPath( path, drive );
       
  4479                 }
       
  4480             else
       
  4481                 {
       
  4482                 // memory card full
       
  4483                 resourceId = R_NOTE_TEXT_NOT_ENOUGH_MEMORY_CARD_DEFAULTNAME;
       
  4484                 // Get the root path of the memory.
       
  4485                 DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
       
  4486                 DriveError = PathInfo::GetRootPath( path, drive );
       
  4487                 }
       
  4488             if ( DriveError == KErrNone )
       
  4489                 {
       
  4490                 // %U  parameter
       
  4491                 NumberOfParameters = 1;
       
  4492                 }
       
  4493             else 
       
  4494                 {
       
  4495                 // no %U  parameter
       
  4496                 NumberOfParameters = 0;
       
  4497                 }
       
  4498 
       
  4499             }
       
  4500             break;
       
  4501 
       
  4502         case ECamMemoryStatusInternalFull:
       
  4503             {
       
  4504             if ( currentLocation == ECamMediaStorageMassStorage ) 
       
  4505                 {
       
  4506                 // internal space full
       
  4507                 resourceId = R_NOTE_TEXT_MASSMEMORY_FULL;
       
  4508                 // Get the root path of the memory.
       
  4509                 DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive );
       
  4510                 DriveError = PathInfo::GetRootPath( path, drive );
       
  4511                 }
       
  4512             else
       
  4513                 {
       
  4514                 // internal space full
       
  4515                 resourceId = R_NOTE_TEXT_NOT_ENOUGH_DEVICE_MEMORY;
       
  4516                 // Get the root path of the memory.
       
  4517                 DriveError = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive );
       
  4518                 DriveError = PathInfo::GetRootPath( path, drive );
       
  4519                 }
       
  4520             if ( DriveError == KErrNone )
       
  4521                 {
       
  4522                 // %U  parameter
       
  4523                 NumberOfParameters = 1;
       
  4524                 }
       
  4525             else 
       
  4526                 {
       
  4527                 // no %U  parameter
       
  4528                 NumberOfParameters = 0;
       
  4529                 }
       
  4530             }
       
  4531             break;
       
  4532 
       
  4533         case ECamMemoryStatusCardNotInserted: // fallthrough
       
  4534         case ECamMemoryStatusCardLocked:
       
  4535             {
       
  4536             // card not present or corrupt or locked
       
  4537             resourceId = R_NOTE_TEXT_CARD_NOT_INSERTED;
       
  4538             }
       
  4539             break;
       
  4540     
       
  4541         case ECamMemoryStatusCardReadOnly:
       
  4542             {
       
  4543             // card read-only
       
  4544             resourceId = R_NOTE_TEXT_CARD_READ_ONLY;
       
  4545             }
       
  4546             break;
       
  4547     
       
  4548         default:
       
  4549             {
       
  4550             // invalid status - don't show note
       
  4551             return;
       
  4552             }            
       
  4553         }
       
  4554 
       
  4555     // prevent timeout to standby - stop standby timer
       
  4556     iController.StopIdleTimer();
       
  4557 
       
  4558     if ( iView && ( iStillCaptureView == iView || iVideoCaptureView == iView ) )
       
  4559         {
       
  4560         // Precapture view is visible... Enable the non-fading flag here to keep
       
  4561         // viewfinder visible under the note. The non-fading flag is reset when
       
  4562         // getting the EEventFocusGained event
       
  4563         CCoeControl* container = static_cast<CCamViewBase*>( iView )->Container();
       
  4564         if ( container )
       
  4565             {
       
  4566             RDrawableWindow* window = container->DrawableWindow();
       
  4567             if ( window )
       
  4568                 {
       
  4569                 window->SetNonFading( ETrue );
       
  4570                 }
       
  4571             }
       
  4572         }
       
  4573     if ( NumberOfParameters == 0 )
       
  4574         {
       
  4575         // set error note text
       
  4576         HBufC* text = StringLoader::LoadLC( resourceId );
       
  4577         // show error note
       
  4578         CAknStaticNoteDialog* note = new( ELeave ) CAknStaticNoteDialog;
       
  4579         note->PrepareLC( R_CAM_ERROR_NOTE );
       
  4580         note->SetTextL( *text );
       
  4581         note->RunDlgLD();
       
  4582         CleanupStack::PopAndDestroy( text );
       
  4583         }
       
  4584     else if ( NumberOfParameters == 1 )
       
  4585         {
       
  4586         // set error note text
       
  4587         HBufC* text = StringLoader::LoadLC( resourceId, path, iEikonEnv );
       
  4588         // show error note
       
  4589         CAknStaticNoteDialog* note = new( ELeave ) CAknStaticNoteDialog;
       
  4590         note->PrepareLC( R_CAM_ERROR_NOTE );
       
  4591         note->SetTextL( *text );
       
  4592         note->RunDlgLD();
       
  4593         CleanupStack::PopAndDestroy( text );
       
  4594         }
       
  4595   
       
  4596     // restart standby timer
       
  4597     iController.StartIdleTimer();
       
  4598 
       
  4599     PRINT( _L("Camera <= CCamAppUi::ShowErrorNoteL") );
       
  4600     }
       
  4601 
       
  4602 // ---------------------------------------------------------
       
  4603 // CCamAppUi::ShowOOMNoteL
       
  4604 // Display error note for OOM condition
       
  4605 // ---------------------------------------------------------
       
  4606 //
       
  4607 TInt CCamAppUi::ShowOOMNoteL( TDesC& aLabel, TBool aWithCancel )
       
  4608     {
       
  4609     // prevent timeout to standby - stop standby timer
       
  4610     iController.StopIdleTimer();
       
  4611     
       
  4612     // show OOM note
       
  4613     CAknStaticNoteDialog* note = new( ELeave ) CAknStaticNoteDialog;
       
  4614     if(aWithCancel)
       
  4615     	note->PrepareLC( R_CAM_OOM_NOTE_OK_CANCEL);
       
  4616     else
       
  4617     	note->PrepareLC( R_CAM_OOM_NOTE_OK_EMPTY);
       
  4618     note->SetTextL( aLabel );
       
  4619     TInt ret = note->RunDlgLD();
       
  4620 
       
  4621     // restart standby timer
       
  4622     iController.StartIdleTimer();
       
  4623 
       
  4624     return ret;
       
  4625     }
       
  4626 
       
  4627 // ---------------------------------------------------------
       
  4628 // CCamAppUi::ShowMMCRemovalNoteIfRequiredL
       
  4629 // Shows the mmc removal note if it is required
       
  4630 // ---------------------------------------------------------
       
  4631 //
       
  4632 void 
       
  4633 CCamAppUi::ShowMMCRemovalNoteIfRequiredL()
       
  4634     {
       
  4635     PRINT( _L("Camera => CCamAppUi::ShowMMCRemovalNoteIfRequiredL") );
       
  4636     // If we have detected a removal and not shown the note.
       
  4637     if ( iViewState != ECamViewStateStandby && iMMCRemoveNoteRequired )
       
  4638         {
       
  4639         PRINT( _L("Camera <> Need to show note") );
       
  4640 
       
  4641         iMMCRemoveNoteRequired = EFalse;
       
  4642         // Show the card not inserted note
       
  4643         if( !iSendAsInProgress )
       
  4644             {
       
  4645             PRINT( _L("Camera <> showing note..") );
       
  4646             ShowErrorNoteL( ECamMemoryStatusCardNotInserted );
       
  4647             PRINT( _L("Camera <> ..done") );
       
  4648             }
       
  4649         }
       
  4650     if ( IsDirectViewfinderActive() )
       
  4651         {
       
  4652         TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));
       
  4653         }
       
  4654     PRINT( _L("Camera <= CCamAppUi::ShowMMCRemovalNoteIfRequiredL") );
       
  4655     }
       
  4656 
       
  4657 // ---------------------------------------------------------
       
  4658 // CCamAppUi::CheckMemoryCard
       
  4659 // Check status of the memory card
       
  4660 // ---------------------------------------------------------
       
  4661 //
       
  4662 void CCamAppUi::CheckMemoryCard( TBool& aFull,
       
  4663                                 TCamMemoryStatus& aStatus, TCamMediaStorage aCurrentLocation )
       
  4664     {
       
  4665     // check if memory card is full
       
  4666     aFull = MemoryFull( ECamMediaStorageCard, aCurrentLocation );
       
  4667 
       
  4668     // get status of card
       
  4669     TCamMemoryCardStatus cardStatus = CamUtility::MemoryCardStatus();
       
  4670     switch ( cardStatus )
       
  4671         {
       
  4672         case ECamMemoryCardLocked:
       
  4673             {
       
  4674             // card is locked
       
  4675             aStatus = ECamMemoryStatusCardLocked;
       
  4676             }
       
  4677             break;
       
  4678         case ECamMemoryCardInserted:
       
  4679             {
       
  4680             aStatus = ECamMemoryStatusOK;
       
  4681             }
       
  4682             break;
       
  4683         case ECamMemoryCardNotInserted:
       
  4684         default:
       
  4685             {
       
  4686             aStatus = ECamMemoryStatusCardNotInserted;
       
  4687             }
       
  4688             break;        
       
  4689         }
       
  4690     }
       
  4691 
       
  4692 // ---------------------------------------------------------
       
  4693 // CCamAppUi::MemoryFull
       
  4694 // Check if the memory location (phone or card) is full
       
  4695 // ---------------------------------------------------------
       
  4696 //
       
  4697 TBool 
       
  4698 CCamAppUi::MemoryFull( TCamMediaStorage aStorage, 
       
  4699                        TCamMediaStorage aCurrentLocation )
       
  4700     {
       
  4701     PRINT( _L("Camera => CCamAppUi::MemoryFull") );
       
  4702     TBool cardFull = ETrue;
       
  4703 
       
  4704     if ( iMode != ECamControllerVideo )
       
  4705         {
       
  4706         // check there is space for image(s)
       
  4707         TInt numImages = iController.ImagesRemaining( aStorage, IsBurstEnabled() );
       
  4708 
       
  4709         // at least 1 image for still capture and 2 for sequence capture
       
  4710         if ( ( iImageMode == ECamImageCaptureSingle && numImages > 0 ) ||
       
  4711                 numImages > 1 )
       
  4712             {
       
  4713             cardFull = EFalse;
       
  4714             }            
       
  4715         else
       
  4716             {
       
  4717             cardFull = ETrue;
       
  4718             }
       
  4719         }
       
  4720     else // capture mode is video
       
  4721         {
       
  4722         // If we want to know the remaining time at the current storage location
       
  4723         // we can obtain this from the engine.
       
  4724         if ( aStorage == aCurrentLocation )
       
  4725             {
       
  4726             TTimeIntervalMicroSeconds timeRemaining = iController.RecordTimeRemaining();
       
  4727 
       
  4728             // Check that enough rec time available
       
  4729             // or that we are recording short (MMS) video
       
  4730             if ( timeRemaining >= KMemoryFullVideoRemaining )
       
  4731                 {
       
  4732                 PRINT( _L("Camera <> not full 1") );
       
  4733                 cardFull = EFalse;
       
  4734                 }
       
  4735             else
       
  4736                 {
       
  4737                 PRINT( _L("Camera <> full 1") );
       
  4738                 cardFull = ETrue;
       
  4739                 }
       
  4740             }
       
  4741         else
       
  4742             {
       
  4743             // We want to know how much remaining time is available on the
       
  4744             // storage location not currently in use.
       
  4745             // We don't have a reliable way of estimating this, so we will
       
  4746             // assume that if there is more space available than on the current
       
  4747             // storage location, then the memory is not full.
       
  4748 
       
  4749             TTimeIntervalMicroSeconds phoneMemoryFree = 
       
  4750             CamUtility::MemoryFree( DriveInfo::EDefaultPhoneMemory );
       
  4751             TTimeIntervalMicroSeconds cardMemoryFree =
       
  4752             CamUtility::MemoryFree( DriveInfo::EDefaultRemovableMassStorage );
       
  4753             TTimeIntervalMicroSeconds MassMemoryFree =
       
  4754             CamUtility::MemoryFree( DriveInfo::EDefaultMassStorage );
       
  4755             if ( aCurrentLocation == ECamMediaStoragePhone )
       
  4756                 {
       
  4757                 if ( phoneMemoryFree > cardMemoryFree
       
  4758                      && phoneMemoryFree > MassMemoryFree
       
  4759                 )
       
  4760                     {
       
  4761                     PRINT( _L("Camera <> full 2") );
       
  4762                     cardFull = ETrue;
       
  4763                     }
       
  4764                 else
       
  4765                     {
       
  4766                     PRINT( _L("Camera <> not full 2") );
       
  4767                     cardFull = EFalse;
       
  4768                     }
       
  4769                 }
       
  4770             else if ( aCurrentLocation == ECamMediaStorageMassStorage )
       
  4771                 {
       
  4772                 if ( MassMemoryFree > cardMemoryFree
       
  4773                         && MassMemoryFree > phoneMemoryFree )
       
  4774                     {
       
  4775                     PRINT( _L("Camera <> full 3") );
       
  4776                     cardFull = ETrue;
       
  4777                     }
       
  4778                 else
       
  4779                     {
       
  4780                     PRINT( _L("Camera <> not full 3") );
       
  4781                     cardFull = EFalse;
       
  4782                     }
       
  4783                 }
       
  4784             else
       
  4785                 {
       
  4786                 if ( cardMemoryFree > phoneMemoryFree 
       
  4787                      && cardMemoryFree > MassMemoryFree )
       
  4788                     {
       
  4789                     PRINT( _L("Camera <> full 4") );
       
  4790                     cardFull = ETrue;
       
  4791                     }
       
  4792                 else
       
  4793                     {
       
  4794                     PRINT( _L("Camera <> not full 4") );
       
  4795                     cardFull = EFalse;
       
  4796                     }
       
  4797                 }
       
  4798             }
       
  4799         }
       
  4800 
       
  4801     PRINT1( _L("Camera <= CCamAppUi::MemoryFull, full:%d"), cardFull );
       
  4802     return cardFull;
       
  4803     }
       
  4804 
       
  4805 // ---------------------------------------------------------
       
  4806 // CCamAppUi::StartCaptureL
       
  4807 // Starts the video/photo capture
       
  4808 // ---------------------------------------------------------
       
  4809 //
       
  4810 TKeyResponse 
       
  4811 CCamAppUi::StartCaptureL( const TKeyEvent& /*aKeyEvent*/ )
       
  4812     {
       
  4813     PRINT( _L("Camera => CCamAppUi::StartCaptureL") );
       
  4814     iLensCoverExit = EFalse; 
       
  4815     if ( iMode != ECamControllerVideo )
       
  4816         {
       
  4817         // Check for active viewfinder before proceeding with capture
       
  4818         if ( !iController.IsViewFinding() )
       
  4819           {
       
  4820           // VF not active - stop capture
       
  4821           PRINT( _L("Camera <= CCamAppUi::StartCaptureL, not vf") );
       
  4822           return EKeyWasNotConsumed;
       
  4823           }
       
  4824         // If the view is in self-timer mode, pressing of the shutter
       
  4825         // button initiates the timer...
       
  4826         if ( iInSelfTimerMode != ECamSelfTimerDisabled )
       
  4827             {
       
  4828             __ASSERT_DEBUG( iSelfTimer, CamPanic( ECamPanicNullPointer ) );
       
  4829             // Will start timer if not already started.  
       
  4830             // If already started, forces capture NOW.
       
  4831             /*iSelfTimer->StartSelfTimer();
       
  4832 
       
  4833             // Change CBA to be SK1 (Blank) SK2 (Cancel)
       
  4834             UpdateCba();*/
       
  4835             HandleCommandL(ECamCmdSelfTimerActivate);
       
  4836             }
       
  4837         else // Not in SelfTimer mode so just take the photo.
       
  4838             {
       
  4839             if ( iController.IsProcessingCapture() )
       
  4840                 {
       
  4841                 PRINT( _L("Camera <= CCamAppUi::StartCaptureL - already processing - ignored capture key") );
       
  4842                 return EKeyWasNotConsumed;
       
  4843                 }
       
  4844 
       
  4845             // Start capture
       
  4846             iController.Capture();
       
  4847 
       
  4848             // Ensure softkeys are correct for sequence
       
  4849             if ( IsBurstEnabled() )            
       
  4850                 {
       
  4851                 if( ECamImageCaptureBurst == iImageMode )
       
  4852                     {
       
  4853                     //Disable cancel autofocus and capture functionality from now on until burst is finished.
       
  4854                     PRINT( _L("Camera <> CCamAppUi::StartCaptureL, SetNoBurstCancel( ETrue )") );
       
  4855 	                  iController.SetKeyUp();
       
  4856                     iController.SetNoBurstCancel( ETrue );
       
  4857                     }
       
  4858                 // Make sure cancel softkey is displayed
       
  4859                 iPreventActivePaletteDisplay = ETrue;
       
  4860                 static_cast<CCamViewBase*>( iView )->UnsetCourtesySoftKeysL();
       
  4861                 // Change CBA to be SK1 (Blank) SK2 (Cancel)
       
  4862                 UpdateCba();
       
  4863 
       
  4864                 // disable timeout to standby during burst capture
       
  4865                 iController.StopIdleTimer();
       
  4866                 }            
       
  4867             }
       
  4868         // Shutter key - full press -> perform capture
       
  4869         PRINT( _L("Camera <= CCamAppUi::StartCaptureL, image capture requested") );
       
  4870         return EKeyWasConsumed;           
       
  4871         }
       
  4872 
       
  4873     // video capture mode 
       
  4874     else 
       
  4875         {
       
  4876         // check for available space before proceeding with capture
       
  4877         TInt callType( EPSCTsyCallTypeUninitialized );
       
  4878         RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, callType );
       
  4879         // video call or no memory available - stop capture
       
  4880         if ( callType == EPSCTsyCallTypeH324Multimedia || !iController.IsViewFinding() || !CheckMemoryL() )
       
  4881             {
       
  4882             PRINT( _L("Camera <= CCamAppUi::StartCaptureL, video no memory") );
       
  4883             return EKeyWasNotConsumed;
       
  4884             }
       
  4885         PERF_EVENT_END_L1( EPerfEventKeyToCapture );
       
  4886         PERF_EVENT_START_L1( EPerfEventStartVideoRecording );    
       
  4887         static_cast<CCamViewBase*>( iView )->UnsetCourtesySoftKeysL();
       
  4888         iController.StartVideoRecordingL();
       
  4889         PRINT( _L("Camera <= CCamAppUi::StartCaptureL, video capture requested") );
       
  4890         return EKeyWasConsumed;
       
  4891         }
       
  4892     }
       
  4893 
       
  4894 // ---------------------------------------------------------
       
  4895 // CCamAppUi::EndCapture
       
  4896 // Stops the capture of video
       
  4897 // ---------------------------------------------------------
       
  4898 //
       
  4899 void CCamAppUi::EndCapture()
       
  4900     {
       
  4901     PRINT( _L("Camera => CCamAppUi::EndCapture") );
       
  4902     if ( ECamControllerVideo == iMode && !iController.IsDemandKeyRelease() )
       
  4903         {
       
  4904         TCamCaptureOperation operation = iController.CurrentOperation();
       
  4905         // if in video recording or paused state
       
  4906         if ( ECamCapturing == operation
       
  4907                 || ECamPaused    == operation )  
       
  4908             {
       
  4909             // if already requested to stop the recording
       
  4910             // but the operation hasn't completed yet
       
  4911             // then just return
       
  4912             if ( iWaitTimer->IsActive() )
       
  4913                 {
       
  4914                 return;
       
  4915                 }
       
  4916 
       
  4917             ZoomPane()->StopZoom();
       
  4918             ZoomPane()->MakeVisible( EFalse, ETrue );
       
  4919             // ignore any errors (eg out of memory)
       
  4920             TRAP_IGNORE( SetSoftKeysL( R_CAM_SOFTKEYS_BLANK ) );
       
  4921             TRAP_IGNORE( DisplayWaitDialogL() );
       
  4922             // give the wait dialog a chance to display itself
       
  4923             iWaitTimer->Start( 0, 0,  TCallBack( StopVideoRecording, this ) );   
       
  4924             }
       
  4925         }
       
  4926     PRINT( _L("Camera <= CCamAppUi::EndCapture") );
       
  4927     }
       
  4928 
       
  4929 // ---------------------------------------------------------
       
  4930 // CCamAppUi::SwitchOrientationIfRequiredL
       
  4931 // Change to the new orientation if necessary
       
  4932 // ---------------------------------------------------------
       
  4933 //    
       
  4934 void CCamAppUi::SwitchOrientationIfRequiredL( TInt aNewOrientation )
       
  4935     {
       
  4936     TInt error = KErrNone;
       
  4937     // No orientation specified, find the default orientation
       
  4938     if ( aNewOrientation == EAppUiOrientationUnspecified )
       
  4939         {
       
  4940         if ( iController.UiConfigManagerPtr()->IsSecondaryCameraSupported() ) 
       
  4941             {
       
  4942             // Default orientation is determined by current active camera
       
  4943             if ( IsSecondCameraEnabled() && !IsQwerty2ndCamera() )   
       
  4944                 {
       
  4945                 error = CamUtility::GetPsiInt( ECamPsiSecondaryCameraOrientation, aNewOrientation );
       
  4946                 }
       
  4947             else
       
  4948                 {
       
  4949                 error = CamUtility::GetPsiInt( ECamPsiPrimaryCameraOrientation, aNewOrientation );
       
  4950                 }
       
  4951             }
       
  4952         else
       
  4953             {
       
  4954             error = CamUtility::GetPsiInt( ECamPsiOrientation, aNewOrientation );
       
  4955             }
       
  4956         }    
       
  4957     TAppUiOrientation currentOrientation = Orientation();        
       
  4958     if ( !error && ( aNewOrientation != currentOrientation ) )
       
  4959         {
       
  4960         PRINT( _L("Camera => CCamAppUi::SwitchOrientationIfRequiredL set orient" ))
       
  4961         SetOrientationL( static_cast<TAppUiOrientation>( aNewOrientation ) );
       
  4962         }
       
  4963     }
       
  4964 
       
  4965 // ---------------------------------------------------------
       
  4966 // CCamAppUi::HandleScreenDeviceChangedL
       
  4967 // Handle change of orientation etc.
       
  4968 // ---------------------------------------------------------
       
  4969 //
       
  4970 void CCamAppUi::HandleScreenDeviceChangedL()
       
  4971     {
       
  4972     PRINT( _L("Camera => CCamAppUi::HandleScreenDeviceChangedL") )
       
  4973     CAknAppUiBase::HandleScreenDeviceChangedL();
       
  4974     if ( iEngineConstructionDelayed )
       
  4975         {
       
  4976         PRINT( _L("CCamAppUi::HandleScreenDeviceChangedL continuing engine construction") );  
       
  4977         iEngineConstructionDelayed = EFalse;
       
  4978         iController.CompleteConstructionL();
       
  4979         // Don't set the target mode here. If the application is not embedded
       
  4980         // the mode will already be correct. If embedded, the target mode is set
       
  4981         // when the HandleNewFileL function is called.
       
  4982         iTargetViewState = ECamViewStatePreCapture;
       
  4983 
       
  4984         // pre-construct side-pane & zoom pane
       
  4985         // get whether we overlay sidepane over view-finder
       
  4986         TBool overlayViewFinder = EFalse;
       
  4987         User::LeaveIfError( CamUtility::GetPsiInt( ECamPsiOverLaySidePane, overlayViewFinder ) );
       
  4988 
       
  4989         iCamSidePane = CCamSidePane::NewL( iController, overlayViewFinder );
       
  4990         User::LeaveIfError(iResourceLoaders.Append(iCamSidePane));
       
  4991 
       
  4992         iCamZoomPane = CCamZoomPane::NewL( iController, overlayViewFinder );
       
  4993         User::LeaveIfError(iResourceLoaders.Append(iCamZoomPane));
       
  4994 
       
  4995         // Exit standby mode now 
       
  4996         // (unless still waiting for HandleNewFileL command - embedded only)
       
  4997         if ( IsConstructionComplete() )
       
  4998             {   
       
  4999             // make sure standby exits as this may not actually result in 
       
  5000             // a view switch if the correct view is already activated
       
  5001             if( iView )
       
  5002                 {
       
  5003                 iView->HandleCommandL( ECamCmdExitStandby ); 
       
  5004                 }
       
  5005 
       
  5006             iViewState = ECamViewStatePreCapture;      
       
  5007             TrySwitchViewL();                    
       
  5008             } 
       
  5009         }
       
  5010 
       
  5011     if ( iController.UiConfigManagerPtr()->IsSecondaryCameraSupported() )
       
  5012         {
       
  5013         if ( iCameraSwitchDelayed )       
       
  5014             {
       
  5015             PRINT( _L("CCamAppUi::HandleScreenDeviceChangedL restarting switch camera") );  
       
  5016             iCameraSwitchDelayed = EFalse;
       
  5017             iController.SwitchCameraL(); 
       
  5018             // The keys will have been blanked - update them
       
  5019             static_cast<CCamViewBase*>( iView )->UpdateCbaL();
       
  5020             }
       
  5021         }
       
  5022     PRINT( _L("Camera <= CCamAppUi::HandleScreenDeviceChangedL") );
       
  5023     }
       
  5024 
       
  5025 // ---------------------------------------------------------
       
  5026 // CCamAppUi::StopVideoRecording
       
  5027 // Stops the video recording
       
  5028 // ---------------------------------------------------------
       
  5029 //
       
  5030 TInt CCamAppUi::StopVideoRecording( TAny* aAny )
       
  5031     {
       
  5032     PRINT( _L("Camera => CCamAppUi::StopVideoRecording") );
       
  5033     CCamAppUi* appui = static_cast<CCamAppUi*>( aAny );
       
  5034     __ASSERT_DEBUG( appui != NULL && appui->iWaitTimer != NULL, CamPanic( ECamPanicNullPointer ) );
       
  5035     appui->iWaitTimer->Cancel();
       
  5036     appui->iController.StopVideoRecordingAsync();
       
  5037     PRINT( _L("Camera <= CCamAppUi::StopVideoRecording") );
       
  5038     return KErrNone;
       
  5039     }
       
  5040 
       
  5041 // ---------------------------------------------------------
       
  5042 // CCamAppUi::CallExit
       
  5043 // Exit the application
       
  5044 // ---------------------------------------------------------
       
  5045 //
       
  5046 TInt CCamAppUi::CallExit( TAny* aAny )
       
  5047     {
       
  5048     PRINT( _L("Camera => CCamAppUi::CallExit") )
       
  5049     CCamAppUi* appui = static_cast<CCamAppUi*>( aAny );
       
  5050     __ASSERT_DEBUG( appui != NULL && appui->iWaitTimer != NULL, CamPanic( ECamPanicNullPointer ) );
       
  5051     appui->iWaitTimer->Cancel();
       
  5052     appui->Exit();
       
  5053     return KErrNone;
       
  5054     }
       
  5055 
       
  5056 // ---------------------------------------------------------
       
  5057 // CCamAppUi::CloseAppL
       
  5058 // Exit the application
       
  5059 // ---------------------------------------------------------
       
  5060 //
       
  5061 void CCamAppUi::CloseAppL()  
       
  5062     {
       
  5063     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_CLOSEAPPL, "e_CCamAppUi_CloseAppL 1" );
       
  5064     
       
  5065     PRINT( _L("Camera => CCamAppUi::CloseAppL") )
       
  5066 
       
  5067     // cancel the self timer if active - can be active
       
  5068     // if closing the slide while counting down
       
  5069     if ( iInSelfTimerMode != ECamSelfTimerDisabled )
       
  5070         {
       
  5071         SelfTimerEnableL( ECamSelfTimerDisabled );
       
  5072         }
       
  5073 
       
  5074     // if we are exiting cam app, we dont need any updates
       
  5075     // for the navipane
       
  5076     if ( NULL != iNaviCounterControl && NULL != iNaviPaneCounterControl && 
       
  5077          NULL != iNaviProgressBarControl && NULL != iNaviPaneProgressBarControl )
       
  5078         { 
       
  5079         UpdateNaviModelsL( EFalse );
       
  5080         }
       
  5081 
       
  5082     if ( iEikonEnv->StartedAsServerApp() )
       
  5083         {
       
  5084         TCamCaptureOperation operation( iController.CurrentOperation() );
       
  5085 
       
  5086         // If recording a video, ensure exit after video recording process has completed
       
  5087         if( ECamControllerVideo == iMode
       
  5088                 && ( ECamCapturing == operation
       
  5089                   || ECamPausing   == operation
       
  5090                   || ECamPaused    == operation
       
  5091                   || ECamResuming  == operation ) )
       
  5092             {
       
  5093             iController.EnterShutdownMode( EFalse );            
       
  5094             }
       
  5095         // Otherwise, close application immediately.
       
  5096         else
       
  5097             {
       
  5098             iController.EnterShutdownMode( ETrue );
       
  5099             Exit();            
       
  5100             }
       
  5101         }
       
  5102     else
       
  5103         {
       
  5104         // this will exit when any current process completes
       
  5105         iController.EnterShutdownMode( EFalse );
       
  5106         }
       
  5107     PRINT( _L("Camera <= CCamAppUi::CloseAppL") )        
       
  5108     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP_CCAMAPPUI_CLOSEAPPL, "e_CCamAppUi_CloseAppL 0" );
       
  5109     
       
  5110     }
       
  5111 
       
  5112 // ---------------------------------------------------------
       
  5113 // CCamAppUi::InternalExitL
       
  5114 // Exit the application from an internal call - this often means
       
  5115 // just going to the background and resetting the settings/modes
       
  5116 // ---------------------------------------------------------
       
  5117 //
       
  5118 void CCamAppUi::InternalExitL()
       
  5119     {
       
  5120     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_INTERNALEXITL, "e_CCamAppUi_InternalExitL 1" );
       
  5121     
       
  5122     PRINT( _L("Camera => CCamAppUi::InternalExitL") );
       
  5123 
       
  5124     iController.StoreFaceTrackingValue(); // store the current FT setting
       
  5125 	
       
  5126     if ( iController.UiConfigManagerPtr() && 
       
  5127          iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  5128         {
       
  5129         // If record location setting is on, stop location trail
       
  5130         if ( ECamLocationOn == iController.IntegerSettingValue( ECamSettingItemRecLocation ) )
       
  5131           	{
       
  5132           	// The parameter ETrue for also closing the session to location utility server
       
  5133           	// when exiting camera.
       
  5134           	iController.StopLocationTrail( ETrue );
       
  5135           	}
       
  5136         }
       
  5137     
       
  5138     if( !iController.IsSavingInProgress() )
       
  5139         {
       
  5140         iController.ReleaseArray(ETrue);  
       
  5141         }
       
  5142     
       
  5143     if ( iEikonEnv->StartedAsServerApp() || !iController.AlwaysOnSupported() )
       
  5144         {
       
  5145         CloseAppL(); 
       
  5146         }
       
  5147     else if ( SettingsLaunchedFromCamera() )
       
  5148         {
       
  5149         //If internal exit was called from settings, we need to set the camera to
       
  5150         //background before closing it to prevent view switch and that way ensuring
       
  5151         //that all the camera resources are released in exit.
       
  5152         SendCameraAppToBackgroundL();                
       
  5153         CloseAppL();
       
  5154         }
       
  5155     else
       
  5156         {
       
  5157         // if UI orientetion override is supported or lens cover is not and 
       
  5158 		// exiting 2ndary camera, set cameraswitch to main camera since 
       
  5159 		// always starting in maincamera stillmode
       
  5160         if ( iController.UiConfigManagerPtr() &&
       
  5161              ( iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() || 
       
  5162                !iController.UiConfigManagerPtr()->IsLensCoverSupported() ) &&
       
  5163              IsSecondCameraEnabled() )
       
  5164             {
       
  5165             iController.SetCameraSwitchRequired( ESwitchSecondaryToPrimary );    
       
  5166             }       
       
  5167         else if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() )
       
  5168             {
       
  5169             PRINT( _L("Camera <> SetCameraSwitchRequired -> ESwitchToUnknown") );
       
  5170             iController.SetCameraSwitchRequired( ESwitchToUnknown );
       
  5171             }
       
  5172         // cancel the self timer if active - can be active
       
  5173         // if closing the slide while counting down
       
  5174         if ( iInSelfTimerMode != ECamSelfTimerDisabled)
       
  5175             {
       
  5176             SelfTimerEnableL( ECamSelfTimerDisabled );
       
  5177             }
       
  5178           
       
  5179         if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() )
       
  5180             {
       
  5181             iController.SliderCloseEventActioned();
       
  5182             }
       
  5183 
       
  5184         iController.SetEndKeyExitWaiting( EFalse );
       
  5185         PRINT( _L("Camera CCamAppUi::InternalExitL - setting zoom reset pending") );
       
  5186 
       
  5187         iCamZoomPane->ResetToDefaultAfterPrepare( ETrue );
       
  5188         SendCameraAppToBackgroundL();
       
  5189         
       
  5190         // if faster startup feature is supported, always start in stillmode after exit
       
  5191         if ( iController.UiConfigManagerPtr() && 
       
  5192              iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() &&
       
  5193              iMode == ECamControllerVideo )
       
  5194             {
       
  5195             PRINT( _L("Camera <> InternalExitL - switching to still precapture") );
       
  5196             iTargetMode = ECamControllerImage;
       
  5197             iTargetViewState = ECamViewStatePreCapture;
       
  5198             TrySwitchViewL( ETrue );
       
  5199             }
       
  5200         else if ( iView && iViewState != ECamViewStatePreCapture && iReturnedFromPlugin )
       
  5201             {
       
  5202             PRINT( _L("Camera: CCamAppUi::InternalExitL - switching to precapture mode") )
       
  5203             iTargetViewState = ECamViewStatePreCapture;
       
  5204             TrySwitchViewL( ETrue );
       
  5205             }
       
  5206 
       
  5207         // If the application is already in the background but has not released
       
  5208         // the resources (e.g. it was behind an eikon server window and had not yet set 
       
  5209         // the iPretendExit flag) then the view needs to know that the resources should 
       
  5210         // be released now.
       
  5211         // This situation occurs when the application is 'pretending' to exit after a
       
  5212         // slider closed event, but the keypad lock note appeared (but only if it was
       
  5213         // in the middle of capturing a sequence as the exit is delayed for the sequence 
       
  5214         // to complete).
       
  5215         // HandleFocusLoss() releases the resources in situations where the app was
       
  5216         // 'continuing in the background'. This release of resources will only occur
       
  5217         // once as the iContinueInBackground flag is reset as soon as the resources are 
       
  5218         // released.
       
  5219 
       
  5220         if ( iView && iReturnedFromPlugin )
       
  5221             {
       
  5222             PRINT( _L("Camera InternalExitL calling iView->HandleFocusLossL()") );
       
  5223             static_cast<CCamViewBase*>( iView )->HandleFocusLossL();
       
  5224             }
       
  5225         // Reset active palette position. As this is done before pretended exit,
       
  5226         // no AP update is needed when the application is returned to foreground
       
  5227         if( iActivePaletteHandler && iReturnedFromPlugin )
       
  5228             {            
       
  5229             iActivePaletteHandler->ResetToDefaultItem();
       
  5230             // Ensure AP visibility on camera startup (also for 2ndary camera)
       
  5231             // unless UI orientation override is used
       
  5232             if ( iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
       
  5233                 {
       
  5234                 iActivePaletteHandler->SetVisibility( EFalse );	
       
  5235                 }
       
  5236             else    
       
  5237                 {
       
  5238                 iActivePaletteHandler->SetVisibility( ETrue );
       
  5239                 }
       
  5240         if( ECamViewStatePreCapture == iViewState )
       
  5241             {
       
  5242             iDrawPreCaptureCourtesyUI = ETrue;
       
  5243             if ( !iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
       
  5244                 {
       
  5245                 RaisePreCaptureCourtesyUI(EFalse);
       
  5246                 }
       
  5247  
       
  5248             if ( IsSecondCameraEnabled() 
       
  5249                  && !IsEmbedded() )
       
  5250                 {
       
  5251                 if ( ECamControllerVideo == iMode )
       
  5252                     {
       
  5253                     SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__RECORD_SECONDARY );
       
  5254                     }
       
  5255                 else
       
  5256                     {
       
  5257                     SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CAPTURE_SECONDARY );      
       
  5258                     }
       
  5259                 }
       
  5260               }
       
  5261             }
       
  5262 
       
  5263         // Cancel delayed sensor initialization, in case it's still pending when 
       
  5264         // internal exit is requested.
       
  5265         if ( iController.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
  5266             {
       
  5267             CancelSensorIdle();
       
  5268             }
       
  5269 
       
  5270         if ( iController.UiConfigManagerPtr()->IsXenonFlashSupported() )
       
  5271             {
       
  5272             // Reset the flash error status
       
  5273             iController.FlashStatus()->SetFlashError( EFalse );
       
  5274             }
       
  5275 /*#ifndef __WINS__
       
  5276         if ( iSendFileInCall )
       
  5277             {
       
  5278             // bring phone app to fore ground
       
  5279             BringPhoneAppToForeGroundL();
       
  5280             }    
       
  5281 #endif // __WINS__   */
       
  5282         }
       
  5283     
       
  5284     if ( iView && ( iStillCaptureView == iView || iVideoCaptureView == iView )
       
  5285             && ShowPostCaptureView() )
       
  5286         {
       
  5287         SetAssumePostCaptureView( EFalse );
       
  5288         }
       
  5289 
       
  5290     if( iController.IsViewFinding() )
       
  5291         {
       
  5292         iController.StopViewFinder();
       
  5293         iViewFinderStopped = ETrue;        
       
  5294         } 
       
  5295  
       
  5296     PRINT( _L("Camera <= CCamAppUi::InternalExitL") );
       
  5297     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP_CCAMAPPUI_INTERNALEXITL, "e_CCamAppUi_InternalExitL 0" );
       
  5298     
       
  5299     } 
       
  5300 
       
  5301 // ---------------------------------------------------------
       
  5302 // CCamAppUi::CallSwitch
       
  5303 // Switch view
       
  5304 // ---------------------------------------------------------
       
  5305 //
       
  5306 TInt CCamAppUi::CallSwitch( TAny* aAny )
       
  5307     {
       
  5308     CCamAppUi* appui = static_cast<CCamAppUi*>( aAny );
       
  5309     __ASSERT_DEBUG( appui != NULL, CamPanic( ECamPanicNullPointer ) );
       
  5310     appui->iWaitTimer->Cancel();
       
  5311     TRAP_IGNORE( appui->TrySwitchViewL() );
       
  5312     return KErrNone;
       
  5313     }
       
  5314 
       
  5315 
       
  5316 // ---------------------------------------------------------
       
  5317 // CCamAppUi::AppInBackground
       
  5318 // Whether or not the app is in the background
       
  5319 // ---------------------------------------------------------
       
  5320 //
       
  5321 TBool CCamAppUi::AppInBackground( TBool aIncludeNotifier ) const
       
  5322     {
       
  5323     PRINT1( _L("Camera => CCamAppUi::AppInBackground( %d )" ), aIncludeNotifier );
       
  5324     TBool aBackground = EFalse;
       
  5325     // Gets the window group id of the app coming in foreground
       
  5326     TInt windowGroupId = iCoeEnv->WsSession().GetFocusWindowGroup();
       
  5327 
       
  5328     PRINT1( _L("Camera    CCamAppUi::AppInBackground windowGroupId=%d" ), windowGroupId );
       
  5329     
       
  5330     // Check if the window group moving to the front is the AknCapServer.
       
  5331     // This often happens when OOM or out of disk space notes are shown
       
  5332     TBool capServerGroup = CamUtility::IdMatchesName( windowGroupId, KAknCapServer );     
       
  5333 
       
  5334     // AknNotifyServer notifies e.g. Location related events.
       
  5335     TBool nfyServerGroup = CamUtility::IdMatchesName( windowGroupId, KAknNotifyServer );     
       
  5336     
       
  5337 	// KPbkSever - Contacts App; Assign to contacts scenario
       
  5338 	TBool pbkServerGroup = CamUtility::IdMatchesName( windowGroupId, KPbkServer );
       
  5339     PRINT1( _L("Camera    CCamAppUi::AppInBackground iMyWgId=%d" ), iMyWgId );
       
  5340     // if the foreground app is not this app
       
  5341     if ( windowGroupId != iMyWgId )
       
  5342         {
       
  5343         // if another app has the foreground
       
  5344         if ( !capServerGroup 
       
  5345           && !nfyServerGroup
       
  5346 		  && !pbkServerGroup
       
  5347           &&  windowGroupId != iEikonServerWindowGroupId 
       
  5348           &&  windowGroupId != iBTServerWindowGroupId 
       
  5349            )
       
  5350             {
       
  5351             PRINT(_L("Camera    CCamAppUi::AppInBackground non-AKN, non-EIK serv has focus"));
       
  5352             aBackground = ETrue;
       
  5353             }
       
  5354         // if the eikon server has the foreground and we're classing that as
       
  5355         // putting us in the background
       
  5356         else if ( aIncludeNotifier )
       
  5357             {           
       
  5358             // Check whether the new foreground window is an Eikon window
       
  5359             if ( windowGroupId == iEikonServerWindowGroupId )
       
  5360                 {
       
  5361                 PRINT(_L("Camera <> CCamAppUi::AppInBackground EIK SERV HAS FOCUS"));
       
  5362                 aBackground = ETrue;    
       
  5363                 }
       
  5364             // Check if AknCapServer is in the foreground (includes other notes)
       
  5365             else if ( capServerGroup )
       
  5366                 {
       
  5367                 PRINT(_L("Camera <> CCamAppUi::AppInBackground CAP SERV HAS FOCUS"));
       
  5368                 aBackground = ETrue;    
       
  5369                 }
       
  5370             else if( nfyServerGroup )
       
  5371                 {
       
  5372                 PRINT(_L("Camera <> CCamAppUi::AppInBackground Avkon notify server has focus"));
       
  5373                 aBackground = ETrue;
       
  5374                 }
       
  5375             else if ( windowGroupId == iBTServerWindowGroupId )
       
  5376                 {
       
  5377                 PRINT(_L("Camera <> CCamAppUi::AppInBackground BT SERV HAS FOCUS"));
       
  5378                 aBackground = ETrue;
       
  5379                 }    
       
  5380             else // empty statement for lint
       
  5381                 {
       
  5382                 }                
       
  5383             }
       
  5384         else // empty statement for lint
       
  5385             {
       
  5386             }
       
  5387         }
       
  5388     PRINT1( _L("Camera <= CCamAppUi::AppInBackground return(%d)" ), aBackground );
       
  5389     return aBackground;
       
  5390     }
       
  5391 
       
  5392 
       
  5393 // ---------------------------------------------------------
       
  5394 // CCamAppUi::LaunchHelpL
       
  5395 // Launch the context sensitive help application
       
  5396 // ---------------------------------------------------------
       
  5397 //
       
  5398 void CCamAppUi::LaunchHelpL()
       
  5399     {
       
  5400     PRINT( _L("Camera => CCamAppUi::LaunchHelpL") );
       
  5401     TCoeHelpContext helpContext;
       
  5402     helpContext.iMajor = TUid::Uid( KCameraappUID );
       
  5403     
       
  5404     // Check which view is active to obtain the help context
       
  5405     TVwsViewId currentViewId;
       
  5406     TInt err = GetActiveViewId( currentViewId );
       
  5407     if ( err == KErrNone )
       
  5408         {
       
  5409         switch ( currentViewId.iViewUid.iUid )
       
  5410             {
       
  5411             case ECamViewIdStillPreCapture:
       
  5412                 // Still precapture can have multiple modes. We must ask it
       
  5413                 // for the current context.
       
  5414                 iStillCaptureView->GetHelpContext( helpContext );
       
  5415                 break;            
       
  5416             case ECamViewIdStillPostCapture:
       
  5417                 helpContext.iContext = KLCAM_HLP_POST_PHOTO;                    
       
  5418                 break;
       
  5419             case ECamViewIdVideoPreCapture:
       
  5420                 // Video precapture can have multiple modes. We must ask it
       
  5421                 // for the current context.
       
  5422                 iVideoCaptureView->GetHelpContext( helpContext );
       
  5423                 break;
       
  5424             case ECamViewIdVideoPostCapture:
       
  5425                 helpContext.iContext = KLCAM_HLP_POST_VIDEO;
       
  5426                 break;
       
  5427             case ECamViewIdBurstThumbnail:
       
  5428                 helpContext.iContext = KLCAM_HLP_POST_SEQ;
       
  5429                 break;
       
  5430             case ECamViewIdVideoSettings:
       
  5431                 helpContext.iContext = KLCAM_HLP_SETTINGS_VIDEO;
       
  5432                 break;
       
  5433             case ECamViewIdPhotoSettings:
       
  5434                 helpContext.iContext = KLCAM_HLP_SETTINGS_PHOTO;
       
  5435                 break;
       
  5436             case ECamViewIdPhotoUserSceneSetup:
       
  5437                 helpContext.iContext = KLCAM_HLP_SETTINGS_PHOUSER;
       
  5438                 break;
       
  5439             default:
       
  5440                 break;
       
  5441             }                
       
  5442         }
       
  5443     else if ( err == KErrNotFound && iPreCaptureMode == ECamPreCapStandby )
       
  5444         {
       
  5445         // This is a work-around for the problem of GetActiveViewId()
       
  5446         // returning -1 when in the Standby view.
       
  5447         if ( IsEmbedded() )
       
  5448             {
       
  5449             helpContext.iContext = KLCAM_HLP_STANDYBY_EM;
       
  5450             }
       
  5451         else
       
  5452             {
       
  5453             helpContext.iContext = KLCAM_HLP_STANDYBY_EM;
       
  5454             }        
       
  5455         }
       
  5456     else
       
  5457         {
       
  5458         User::Leave( err );
       
  5459         }    
       
  5460 
       
  5461     PRINT1( _L("Camera <> CCamAppUi::LaunchHelpL, help context: %S"), &(helpContext.iContext) );
       
  5462 
       
  5463     // Create the context array and append the single context item
       
  5464     CArrayFix<TCoeHelpContext>* contextArray = 
       
  5465         new ( ELeave ) CArrayFixFlat<TCoeHelpContext> ( 1 );
       
  5466 
       
  5467     CleanupStack::PushL( contextArray );
       
  5468     contextArray->AppendL( helpContext );
       
  5469     CleanupStack::Pop( contextArray );
       
  5470 
       
  5471     //Launch help - takes ownership of context array
       
  5472     HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
  5473                                          contextArray );
       
  5474 
       
  5475     PRINT( _L("Camera <= CCamAppUi::LaunchHelpL") );
       
  5476     }
       
  5477 
       
  5478 #ifndef __WINS__
       
  5479 // ---------------------------------------------------------
       
  5480 // CCamAppUi::ProcessCommandParametersL
       
  5481 // Allow Camera application to respond to request for in-call send
       
  5482 // functionality from Phone application
       
  5483 // ---------------------------------------------------------
       
  5484 //
       
  5485 TBool CCamAppUi::ProcessCommandParametersL(
       
  5486     TApaCommand aCommand,
       
  5487     TFileName& aDocumentName,
       
  5488     const TDesC8& /*aTail*/ )
       
  5489     {
       
  5490     PRINT( _L("CCamAppUi::ProcessCommandParametersL") );
       
  5491     // Check if we should start in SFI mode
       
  5492 /*    if ( aCommand == EApaCommandOpen && aDocumentName == KSFITrailing )
       
  5493         {
       
  5494         if ( !SFIUtility() )
       
  5495             {
       
  5496             PRINT( _L("CCamAppUi::ProcessCommandParametersL !!") );
       
  5497             return EFalse;
       
  5498             }
       
  5499         SFIUtility()->IsCLIValidL();
       
  5500         
       
  5501         iSendFileInCall = ETrue;
       
  5502         PRINT( _L("CCamAppUi::ProcessCommandParametersL iSendFileInCall = ETrue") );
       
  5503         // Make sure that the static settings are loaded
       
  5504         iController.LoadStaticSettingsL( ETrue );
       
  5505         }*/
       
  5506     return EFalse;
       
  5507     }
       
  5508 
       
  5509 // ---------------------------------------------------------
       
  5510 // CCamAppUi::HandleMessageL
       
  5511 // Bring Camera app to foreground in response to request for in-call send
       
  5512 // ---------------------------------------------------------
       
  5513 //
       
  5514 MCoeMessageObserver::TMessageResponse CCamAppUi::HandleMessageL(
       
  5515     TUint32 aClientHandleOfTargetWindowGroup,
       
  5516     TUid aMessageUid,
       
  5517     const TDesC8& aMessageParameters )
       
  5518     {
       
  5519     PRINT( _L("CCamAppUi::HandleMessageL") );
       
  5520     // Go to SFI mode at run-time if requested by SFIUtils
       
  5521     // using a window server message.
       
  5522     if ( aMessageUid.iUid == 0 && aMessageParameters.Length() > 0 )
       
  5523         {
       
  5524         TInt lengthInCharacters = 
       
  5525             ( aMessageParameters.Length() * sizeof( TUint8 ) ) /
       
  5526             sizeof( TUint16 );
       
  5527         TPtrC message(
       
  5528             reinterpret_cast<const TUint16*>( aMessageParameters.Ptr() ),
       
  5529             lengthInCharacters );
       
  5530 
       
  5531         /*if ( message == KSFITrailing )
       
  5532             {
       
  5533             if ( !SFIUtility() )
       
  5534                 {
       
  5535                 // Jump to foreground anyway, even if SFI mode cannot
       
  5536                 // be activated.
       
  5537                 iEikonEnv->RootWin().SetOrdinalPosition( 0, 0 ); 
       
  5538                 return CAknAppUi::HandleMessageL( 
       
  5539                     aClientHandleOfTargetWindowGroup, 
       
  5540                     aMessageUid, 
       
  5541                     aMessageParameters );
       
  5542                 }
       
  5543 
       
  5544             SFIUtility()->IsCLIValidL();
       
  5545             
       
  5546             iSendFileInCall = ETrue;
       
  5547             PRINT( _L("CCamAppUi::HandleMessageL iSendFileInCall = ETrue") );
       
  5548 
       
  5549             // Jump to foreground
       
  5550             iEikonEnv->RootWin().SetOrdinalPosition( 0, 0 ); 
       
  5551             
       
  5552             // load embedded static settings
       
  5553             iController.LoadStaticSettingsL( ETrue );
       
  5554             }*/
       
  5555         }
       
  5556     return CAknAppUi::HandleMessageL( aClientHandleOfTargetWindowGroup, 
       
  5557         aMessageUid, aMessageParameters);
       
  5558     }
       
  5559 
       
  5560 #endif // HANDLE_TRANSITIONAL_UI    
       
  5561 
       
  5562 // ---------------------------------------------------------
       
  5563 // CCamAppUi::SidePane
       
  5564 // Return reference to side-pane object
       
  5565 // ---------------------------------------------------------
       
  5566 //
       
  5567 CCamSidePane* CCamAppUi::SidePane()
       
  5568     {
       
  5569     return iCamSidePane;
       
  5570     }
       
  5571 
       
  5572 // ---------------------------------------------------------
       
  5573 // CCamAppUi::ZoomPane
       
  5574 // Return reference to zoom-pane object
       
  5575 // ---------------------------------------------------------
       
  5576 //
       
  5577 CCamZoomPane* CCamAppUi::ZoomPane()
       
  5578     {
       
  5579     return iCamZoomPane;
       
  5580     }
       
  5581     
       
  5582 // ---------------------------------------------------------
       
  5583 // CCamAppUi::CurrentViewState
       
  5584 // Return current view state
       
  5585 // ---------------------------------------------------------
       
  5586 //        
       
  5587 TCamViewState CCamAppUi::CurrentViewState() const
       
  5588     {
       
  5589     return iViewState;
       
  5590     }
       
  5591 
       
  5592 // ---------------------------------------------------------
       
  5593 // CCamAppUi::TargetViewState
       
  5594 // Returns target view state
       
  5595 // ---------------------------------------------------------
       
  5596 //        
       
  5597 TCamViewState CCamAppUi::TargetViewState()
       
  5598     {
       
  5599     return iTargetViewState;
       
  5600     }
       
  5601 
       
  5602 // ---------------------------------------------------------
       
  5603 // CCamAppUi::TargetMode
       
  5604 // ---------------------------------------------------------
       
  5605 //  
       
  5606 TCamCameraMode CCamAppUi::TargetMode() const
       
  5607     {
       
  5608     return iTargetMode;
       
  5609     }
       
  5610 
       
  5611 // ---------------------------------------------------------
       
  5612 // CCamAppUi::HandleShutterKeyL
       
  5613 // Handles the shutter key press
       
  5614 // ---------------------------------------------------------
       
  5615 //   
       
  5616 void CCamAppUi::HandleShutterKeyL( TBool aPressed )
       
  5617     {
       
  5618     // only handle the shutter key if the app is
       
  5619     // in the foreground and view finder is active
       
  5620     if ( !AppInBackground( ETrue ) )
       
  5621         {
       
  5622         RArray<TInt> captureKeys;
       
  5623         CleanupClosePushL( captureKeys );
       
  5624         
       
  5625         if ( iController.UiConfigManagerPtr() )
       
  5626             {
       
  5627             iController.UiConfigManagerPtr()->
       
  5628                  SupportedPrimaryCameraCaptureKeyL( captureKeys );
       
  5629             if ( captureKeys.Count() <= 0 )
       
  5630                 {
       
  5631                 User::Leave( KErrNotSupported );
       
  5632                 }
       
  5633             }
       
  5634         TKeyEvent keyEvent;
       
  5635         keyEvent.iScanCode = captureKeys[0];//EProductKeyCapture
       
  5636         keyEvent.iModifiers = 0;
       
  5637         keyEvent.iRepeats = 0;
       
  5638 
       
  5639         CleanupStack::PopAndDestroy( &captureKeys );
       
  5640 
       
  5641         // check we have a currently active view
       
  5642         if( iView )
       
  5643             {
       
  5644             CCoeControl* container = static_cast<CCamViewBase*>( iView )->Container();
       
  5645             if ( container )
       
  5646                 {
       
  5647                 if ( aPressed )
       
  5648                     {
       
  5649                     container->OfferKeyEventL( keyEvent, EEventKeyDown ); 
       
  5650                     }
       
  5651                 else
       
  5652                     {
       
  5653                     container->OfferKeyEventL( keyEvent, EEventKeyUp ); 
       
  5654                     }
       
  5655                 }
       
  5656             }
       
  5657         }
       
  5658     }
       
  5659 
       
  5660 
       
  5661 // ---------------------------------------------------------------------------
       
  5662 // CCamAppUi::HandleVolumeKeyEvent
       
  5663 // 
       
  5664 // ---------------------------------------------------------------------------
       
  5665 //    
       
  5666 void CCamAppUi::HandleVolumeKeyEvent( TRemConCoreApiOperationId aOperationId,
       
  5667                                   TRemConCoreApiButtonAction aButtonAct )
       
  5668     {
       
  5669     PRINT2( _L("Camera => CCamAppUi::HandleVolumeKeyEvent op (%d) act (%d)"), aOperationId, aButtonAct )
       
  5670     
       
  5671     if ( !iZoomUsingVolumeKeys )
       
  5672         {
       
  5673         PRINT( _L("Camera <= CCamAppUi::HandleVolumeKeyEvent NOT zooming with volume keys") )
       
  5674         return;
       
  5675         }
       
  5676     // only handle the shutter key if the app is
       
  5677     // in the foreground and view finder is active
       
  5678     if ( !AppInBackground( ETrue ) )
       
  5679         {
       
  5680         PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent yes"))
       
  5681         // check we have a currently active view
       
  5682         if( iView && ( iCamOrientation == ECamOrientationCamcorder
       
  5683                 || iCamOrientation == ECamOrientationCamcorderLeft) &&
       
  5684                 ECamViewStatePreCapture == iViewState ) // Zoom only needed in precap
       
  5685             {
       
  5686             CCoeControl* container = static_cast<CCamViewBase*>( iView )->Container();
       
  5687             if ( container )
       
  5688                 {
       
  5689                 PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent cont"))
       
  5690                 TKeyEvent keyEvent;
       
  5691                 keyEvent.iModifiers = 0;
       
  5692                 keyEvent.iRepeats = 0; 
       
  5693 
       
  5694                 // map up/down to appropriate zoom key
       
  5695                 if( aOperationId == ERemConCoreApiVolumeUp )
       
  5696                     {
       
  5697                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent up"))
       
  5698                     keyEvent.iScanCode = EStdKeyIncVolume;
       
  5699                     }
       
  5700                 else if( aOperationId == ERemConCoreApiVolumeDown )
       
  5701                     {
       
  5702                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent down"))
       
  5703                     keyEvent.iScanCode = EStdKeyDecVolume;
       
  5704                     }
       
  5705                 else
       
  5706                     {
       
  5707                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent ??"))
       
  5708                     }
       
  5709                 // map event type
       
  5710                 if ( aButtonAct == ERemConCoreApiButtonPress )
       
  5711                     {
       
  5712                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent press"))
       
  5713                     TRAP_IGNORE( container->OfferKeyEventL( keyEvent, EEventKeyDown ) ); 
       
  5714                     }
       
  5715                 else if( aButtonAct == ERemConCoreApiButtonRelease )
       
  5716                     {
       
  5717                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent release"))
       
  5718                     TRAP_IGNORE( container->OfferKeyEventL( keyEvent, EEventKeyUp ) );
       
  5719                     }
       
  5720                 else if( aButtonAct == ERemConCoreApiButtonClick )
       
  5721                     {
       
  5722                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent click"))
       
  5723                     TRAP_IGNORE( container->OfferKeyEventL( keyEvent, EEventUser ) ); 
       
  5724                     }        
       
  5725                 else
       
  5726                     {
       
  5727                     PRINT( _L("Camera <> CCamAppUi::HandleVolumeKeyEvent unhandled volume keypress"))
       
  5728                     }
       
  5729                 }
       
  5730             }
       
  5731         }
       
  5732     PRINT( _L("Camera <= CCamAppUi::HandleVolumeKeyEvent"))
       
  5733     }
       
  5734 
       
  5735   
       
  5736 // ---------------------------------------------------------
       
  5737 // CCamAppUi::SetEmbedding
       
  5738 // Sets embedding flag
       
  5739 // ---------------------------------------------------------
       
  5740 //  
       
  5741 void CCamAppUi::SetEmbedding( TBool aEmbedding )
       
  5742     {
       
  5743     PRINT1( _L("Camera => CCamAppUi::SetEmbedding %d"), aEmbedding )
       
  5744     iEmbedding = aEmbedding;
       
  5745     PRINT( _L("Camera <= CCamAppUi::SetEmbedding") )
       
  5746     }
       
  5747     
       
  5748 // ---------------------------------------------------------
       
  5749 // CCamAppUi::Embedding
       
  5750 // Returns embedding flag
       
  5751 // ---------------------------------------------------------
       
  5752 // 
       
  5753 TBool CCamAppUi::Embedding() const
       
  5754     {
       
  5755     PRINT1( _L("Camera => CCamAppUi::Embedding %d"), iEmbedding )
       
  5756     PRINT( _L("Camera <= CCamAppUi::Embedding") )
       
  5757     return iEmbedding;
       
  5758     }    
       
  5759     
       
  5760 // ---------------------------------------------------------
       
  5761 // CCamAppUi::SetSendAsInProgressL
       
  5762 // Sets the SendAs flag
       
  5763 // ---------------------------------------------------------
       
  5764 // 
       
  5765 void CCamAppUi::SetSendAsInProgressL( TBool aSendAsInProgress )
       
  5766     {
       
  5767     PRINT1( _L("Camera => CCamAppUi::SetSendAsInProgressL %d"), aSendAsInProgress );
       
  5768     // Check before updating embedding status.
       
  5769     TBool exitStatus = iController.CheckExitStatus();
       
  5770 
       
  5771     iSendAsInProgress = aSendAsInProgress;
       
  5772     SetEmbedding( aSendAsInProgress );
       
  5773 
       
  5774     if ( !iSendAsInProgress )
       
  5775         {
       
  5776         PRINT( _L("Camera <> CCamAppUi::SetSendAsInProgressL - checking exit status..") );
       
  5777         // Exit not wanted when embedding / embedded
       
  5778         // Check if camera switch is required.        
       
  5779         if ( exitStatus )
       
  5780             {
       
  5781             InternalExitL();   
       
  5782             }
       
  5783         else if ( iPendingViewSwitch != EPendingViewSwitchNone )
       
  5784             {
       
  5785             iPendingViewSwitch = EPendingViewSwitchNone;        
       
  5786             iWaitTimer->Start( 0, 0,  TCallBack( CallSwitch, this ) ); 
       
  5787             }  
       
  5788         else
       
  5789             {
       
  5790             // Do nothing
       
  5791             }                   
       
  5792         }
       
  5793     PRINT( _L("Camera <= CCamAppUi::SetSendAsInProgressL") );
       
  5794     }     
       
  5795 
       
  5796 // ---------------------------------------------------------
       
  5797 // CCamAppUi::SendAsInProgressL
       
  5798 // Get the SendAs flag value
       
  5799 // ---------------------------------------------------------
       
  5800 // 
       
  5801 TBool CCamAppUi::SendAsInProgress() const
       
  5802     {
       
  5803     return iSendAsInProgress;
       
  5804     }
       
  5805 
       
  5806 
       
  5807 // ---------------------------------------------------------
       
  5808 // CCamAppUi::IsMMCRemoveNotePending
       
  5809 // Return whether an MMC removal note is pending
       
  5810 // ---------------------------------------------------------
       
  5811 //
       
  5812 TBool CCamAppUi::IsMMCRemovedNotePending() const
       
  5813     {
       
  5814     if ( iMMCRemoveNoteRequired || iMMCRemoveNoteRequiredOnCapture )
       
  5815         {
       
  5816         return ETrue;
       
  5817         }
       
  5818     else
       
  5819         {
       
  5820         return EFalse;
       
  5821         }
       
  5822     }
       
  5823 
       
  5824 // ---------------------------------------------------------
       
  5825 // CCamAppUi::HandleCameraErrorL
       
  5826 // Display an error note
       
  5827 // ---------------------------------------------------------
       
  5828 //
       
  5829 void CCamAppUi::HandleCameraErrorL( TInt aError )
       
  5830     {
       
  5831     if( aError == KErrNoMemory )
       
  5832         {
       
  5833         PRINT( _L( "Camera => CCamAppUi::HandleCameraErrorL KErrNoMemory" ) );
       
  5834         HBufC* text = StringLoader::LoadLC( R_CAM_MEMLO_NOT_ENOUGH_MEMORY );
       
  5835         // Display an error note 
       
  5836         CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
       
  5837         dlg->ExecuteLD( *text );
       
  5838 
       
  5839         CleanupStack::PopAndDestroy( text );
       
  5840         }
       
  5841     else if ( aError )
       
  5842         {
       
  5843         PRINT1( _L( "Camera => CCamAppUi::HandleCameraErrorL (%d)" ), aError );
       
  5844 
       
  5845         // Resolve the error text with no context or separator
       
  5846         TPtrC buf;
       
  5847         buf.Set( iTextResolver->ResolveErrorString( aError, CTextResolver::ECtxNoCtxNoSeparator ) );             
       
  5848         
       
  5849         // Display an error note 
       
  5850         CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
       
  5851         dlg->ExecuteLD( buf );
       
  5852 
       
  5853         PRINT( _L( "Camera <= CCamAppUi::HandleCameraErrorL" ) );
       
  5854         }
       
  5855     else
       
  5856         {
       
  5857         }
       
  5858     }
       
  5859     
       
  5860 // ---------------------------------------------------------
       
  5861 // CCamAppUi::TextResolver
       
  5862 // Offers a reference to appui's TextResolver instance
       
  5863 // ---------------------------------------------------------
       
  5864 // 
       
  5865 CTextResolver* CCamAppUi::TextResolver()
       
  5866     {
       
  5867     return iTextResolver;
       
  5868     } 
       
  5869 
       
  5870 
       
  5871 #ifndef __WINS__
       
  5872 // ---------------------------------------------------------
       
  5873 // CCamAppUi::SFIUtility
       
  5874 // Return pointer to in-call send utility object
       
  5875 // ---------------------------------------------------------
       
  5876 //
       
  5877 /*CSFIUtilsAppInterface* CCamAppUi::SFIUtility() const
       
  5878     {
       
  5879     return iSFIUtils;
       
  5880     }*/
       
  5881 
       
  5882 // ---------------------------------------------------------
       
  5883 // CCamAppUi::IsInCallSend
       
  5884 // Return whether in in-call send mode
       
  5885 // ---------------------------------------------------------
       
  5886 //
       
  5887 /*TBool CCamAppUi::IsInCallSend() const
       
  5888     {
       
  5889     return iSendFileInCall;
       
  5890     }*/
       
  5891 
       
  5892 // ---------------------------------------------------------------------------
       
  5893 // CCamAppUi::DoInCallSendL
       
  5894 // Handle send to caller functionality
       
  5895 // ---------------------------------------------------------------------------
       
  5896 //
       
  5897 /*void CCamAppUi::DoInCallSendL() const
       
  5898     {
       
  5899     PRINT( _L("CCamAppUi::DoInCallSendL in") );
       
  5900     if ( iSFIUtils && iSFIUtils->IsCLIValidL() )
       
  5901         {
       
  5902         PRINT( _L("CCamAppUi::DoInCallSendL send") );
       
  5903         iSFIUtils->SendMediaFileL( iController.CurrentFullFileName() );
       
  5904         }
       
  5905     PRINT( _L("CCamAppUi::DoInCallSendL out") );
       
  5906     }  */
       
  5907 
       
  5908 // ---------------------------------------------------------------------------
       
  5909 // CCamAppUi::BringPhoneAppToForeGroundL
       
  5910 // Bring phone application to foreground
       
  5911 // ---------------------------------------------------------------------------
       
  5912 //
       
  5913 void CCamAppUi::BringPhoneAppToForeGroundL()
       
  5914     {
       
  5915     PRINT( _L("CCamAppUi::BringPhoneAppToForeGroundL") );
       
  5916     TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
       
  5917     TApaTask apaTask = apaTaskList.FindApp( KPhoneAppUid );
       
  5918     if ( apaTask.Exists() )
       
  5919         {
       
  5920         apaTask.BringToForeground();
       
  5921         }
       
  5922 
       
  5923     // load non-embedded static settings
       
  5924     iController.LoadStaticSettingsL( EFalse );
       
  5925     // no longer in SFI state
       
  5926 //    iSendFileInCall = EFalse;
       
  5927 
       
  5928     // set us back to pre-capture
       
  5929     iTargetViewState = ECamViewStatePreCapture;   	
       
  5930 	// when camera is used again, TrySwitchViewL() will be called
       
  5931     iPendingViewSwitch = EPendingViewSwitchDeactivateFirst; 
       
  5932 
       
  5933     PRINT( _L("CCamAppUi::BringPhoneAppToForeGroundL iSendFileInCall = EFalse") );
       
  5934     }
       
  5935 
       
  5936 #endif
       
  5937 
       
  5938 // ---------------------------------------------------------
       
  5939 // CCamAppUi::IsInPretendExit
       
  5940 // Indicates whether or not the application is in a simulated exit situation
       
  5941 // ---------------------------------------------------------
       
  5942 // 
       
  5943 TBool CCamAppUi::IsInPretendExit() const
       
  5944     {
       
  5945     return iPretendExit;
       
  5946     }  
       
  5947 
       
  5948 // ---------------------------------------------------------------------------
       
  5949 // CCamAppUi::SendCameraAppToBackgroundL
       
  5950 // Sends the camera application to the background, to pretend we're closing
       
  5951 // ---------------------------------------------------------------------------
       
  5952 //
       
  5953 void CCamAppUi::SendCameraAppToBackgroundL()
       
  5954     {
       
  5955     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMAPPUI_SENDCAMERAAPPTOBACKGROUNDL, "e_CCamAppUi_SendCameraAppToBackgroundL 1" );
       
  5956     
       
  5957     PRINT( _L("Camera => CCamAppUi::SendCameraAppToBackgroundL") );
       
  5958     // Pretend we're closing, so reset the dynamic settings.
       
  5959     iController.SetDynamicSettingsToDefaults();
       
  5960 
       
  5961     // stop listening mmc dismount notifications
       
  5962     iController.CancelDismountMonitoring();
       
  5963     
       
  5964     // Switch sequence capture off if the app is going to pretend to close
       
  5965     if ( IsBurstEnabled() )
       
  5966         {
       
  5967         PRINT( _L("CCamAppUi::SendCameraAppToBackgroundL calling ToggleMulti") );
       
  5968         SwitchStillCaptureModeL( ECamImageCaptureSingle, EFalse );
       
  5969         }
       
  5970 
       
  5971     // Send the task with the given WgId to the background 
       
  5972     CAknSgcClient::MoveApp( iMyWgId, ESgcMoveAppToBackground );
       
  5973 
       
  5974     // Hide from task list/FSW and send to background
       
  5975     HideTaskL( ETrue );    		
       
  5976     iPretendExit = ETrue;
       
  5977     iFirstVFStart = ETrue;
       
  5978 
       
  5979     PRINT( _L("Camera <= CCamAppUi::SendCameraAppToBackgroundL") );
       
  5980     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMAPPUI_SENDCAMERAAPPTOBACKGROUNDL, "e_CCamAppUi_SendCameraAppToBackgroundL 0" );
       
  5981 
       
  5982     }
       
  5983 
       
  5984 // ---------------------------------------------------------------------------
       
  5985 // CCamAppUi::HideTaskL
       
  5986 // Hides or shows the Camera app task in the tasklist
       
  5987 // ---------------------------------------------------------------------------
       
  5988 // 
       
  5989 void CCamAppUi::HideTaskL(TBool aHide)
       
  5990     {
       
  5991     // HideApplicationFromFSW also hides running status from menu grid
       
  5992    	HideApplicationFromFSW( aHide );
       
  5993 
       
  5994 	// The following ensures that the task is hidden even if an embedded camera app is also running    
       
  5995     RWsSession session = iEikonEnv->WsSession();
       
  5996     CApaWindowGroupName* wgName = CApaWindowGroupName::NewL( session, iMyWgId );
       
  5997     wgName->SetHidden( aHide );
       
  5998     wgName->SetWindowGroupName( iEikonEnv->RootWin() );
       
  5999     delete wgName;
       
  6000     }
       
  6001     
       
  6002 // ---------------------------------------------------------
       
  6003 // CCamAppUi::StartAsServerAppL
       
  6004 // Start application as file server application
       
  6005 // ---------------------------------------------------------
       
  6006 //
       
  6007 void 
       
  6008 CCamAppUi::StartAsServerAppL( MCamEmbeddedObserver* aEmbeddedObserver, 
       
  6009                               TInt                  aMode )
       
  6010     {       
       
  6011     PRINT( _L("Camera => CCamAppUi::StartAsServerAppL") );  
       
  6012 
       
  6013     __ASSERT_ALWAYS( aMode == ECamControllerVideo || aMode == ECamControllerImage, 
       
  6014             CamPanic( ECamPanicNotSupported ) );
       
  6015 
       
  6016     // Load Embedded Settings
       
  6017     iController.LoadStaticSettingsL( ETrue );
       
  6018     iEmbeddedViewSet = ETrue;     
       
  6019     iEmbeddedObserver = aEmbeddedObserver; 
       
  6020     iTargetViewState = ECamViewStatePreCapture;
       
  6021 
       
  6022 
       
  6023     if ( aMode == ECamControllerVideo )
       
  6024         {
       
  6025         iTargetMode = ECamControllerVideo;
       
  6026         }
       
  6027     else if ( aMode == ECamControllerImage )
       
  6028         {
       
  6029         iTargetMode = ECamControllerImage;
       
  6030         }
       
  6031 
       
  6032     // Find the parent app's name:
       
  6033 
       
  6034     RWsSession ws = iEikonEnv->WsSession();
       
  6035 
       
  6036     // Get a list of the names and IDs of the all the window groups
       
  6037     RArray<RWsSession::TWindowGroupChainInfo> windowList;
       
  6038     CleanupClosePushL(windowList);
       
  6039 
       
  6040     // Get a list of window group IDs
       
  6041     User::LeaveIfError(ws.WindowGroupList(&windowList));
       
  6042 
       
  6043     // Find our window group ID
       
  6044     RThread thread;
       
  6045     TInt cameraWindowGroup = ws.FindWindowGroupIdentifier(0, thread.Id());
       
  6046     thread.Close();
       
  6047 
       
  6048     TInt parentID = 0;
       
  6049     TBool found = EFalse;
       
  6050 
       
  6051     // Find our window ID in the list, to look up the parent ID
       
  6052     for( TInt i = 0; !found && i < windowList.Count(); i++ )
       
  6053         {
       
  6054         RWsSession::TWindowGroupChainInfo windowInfo = windowList[i];
       
  6055         if ( windowInfo.iId == cameraWindowGroup )
       
  6056             {
       
  6057             parentID = windowInfo.iParentId;
       
  6058             found = ETrue;
       
  6059             }
       
  6060         }
       
  6061 
       
  6062     CleanupStack::PopAndDestroy(&windowList);
       
  6063 
       
  6064     if ( found )
       
  6065         {
       
  6066         TBuf<100> windowName;
       
  6067         ws.GetWindowGroupNameFromIdentifier( parentID, windowName );
       
  6068 
       
  6069         // The format of windowName is:
       
  6070         // [number][zero-char][UID of app][zero-char][Title of window][zero-char]
       
  6071         // We want to discard everything up to the window title:
       
  6072         for ( TInt t = 0; t  < 2; t++ )
       
  6073             {
       
  6074             TInt zeroPos = windowName.Locate(0);
       
  6075 
       
  6076             if ( zeroPos != KErrNotFound 
       
  6077                     && zeroPos < windowName.Length() )
       
  6078                 {
       
  6079                 windowName.Delete(0, zeroPos + 1);
       
  6080                 }
       
  6081             }
       
  6082 
       
  6083         // And the final zero-char
       
  6084         if ( windowName.Length() > 0 )
       
  6085             {
       
  6086             if ( windowName[windowName.Length() - 1] == 0 )
       
  6087                 {
       
  6088                 windowName.Delete(windowName.Length() - 1, 1);
       
  6089                 }
       
  6090             }
       
  6091 
       
  6092         if ( windowName.Length() > 0 )
       
  6093             {
       
  6094             iParentAppName = HBufC::NewL(windowName.Length());
       
  6095             iParentAppName->Des().Copy(windowName);
       
  6096 
       
  6097             SetTitleL(windowName);
       
  6098             }
       
  6099         else
       
  6100             {
       
  6101             // Something's wrong - act as if we haven't found it
       
  6102             found = EFalse;
       
  6103             }
       
  6104         }
       
  6105 
       
  6106     // We were unable to find the parent app's name, so fall back on our own app title        
       
  6107     if( !found )
       
  6108         {
       
  6109         iParentAppName = StringLoader::LoadL(R_CAM_GENERIC_TITLE_NAME);
       
  6110         }
       
  6111 
       
  6112     // make sure standby exits as this may not actually result in 
       
  6113     // a view switch if the correct view is already activated
       
  6114     if( iView )
       
  6115         {
       
  6116         iView->HandleCommandL( ECamCmdExitStandby );
       
  6117         }
       
  6118     iViewState = ECamViewStatePreCapture;    
       
  6119   iTargetViewState = ECamViewStatePreCapture;   	
       
  6120     TrySwitchViewL();                                      
       
  6121 
       
  6122 
       
  6123     PRINT( _L("Camera <= CCamAppUi::StartAsServerAppL") );
       
  6124     }
       
  6125            
       
  6126 
       
  6127 // ---------------------------------------------------------------------------
       
  6128 // CCamAppUi::CamOrientation
       
  6129 // Returns the current orientation of the app
       
  6130 // ---------------------------------------------------------------------------
       
  6131 //
       
  6132 TCamOrientation CCamAppUi::CamOrientation()
       
  6133     {
       
  6134     return iCamOrientation;
       
  6135     }
       
  6136 
       
  6137 // ---------------------------------------------------------------------------
       
  6138 // CCamAppUi::SetCamOrientationToLandscape()
       
  6139 // Set the current orientation as landscape
       
  6140 // ---------------------------------------------------------------------------
       
  6141 //
       
  6142 void CCamAppUi::SetCamOrientationToLandscape()
       
  6143     {
       
  6144     iCamOrientation = (ECamHandLeft == iSoftkeyPosition ) 
       
  6145                     ? ECamOrientationCamcorderLeft 
       
  6146                     : ECamOrientationCamcorder;
       
  6147     }
       
  6148 
       
  6149 // ---------------------------------------------------------------------------
       
  6150 // CCamAppUi::AppUiOrientation
       
  6151 // Returns the AppUi orientation (e.g. Portrait or Landscape) for the given product-specific orientation
       
  6152 // ---------------------------------------------------------------------------
       
  6153 //
       
  6154 CAknAppUiBase::TAppUiOrientation CCamAppUi::AppUiOrientation(TCamOrientation aCamOrientation)
       
  6155     {
       
  6156     switch ( aCamOrientation )
       
  6157         {
       
  6158         case ECamOrientationCamcorder: // fallthrough
       
  6159         case ECamOrientationCamcorderLeft:
       
  6160             {
       
  6161             return CAknAppUiBase::EAppUiOrientationLandscape;
       
  6162             }
       
  6163         case ECamOrientationViewMode:
       
  6164             {
       
  6165             return CAknAppUiBase::EAppUiOrientationLandscape;
       
  6166             }
       
  6167         case ECamOrientationPortrait:
       
  6168             {
       
  6169             return CAknAppUiBase::EAppUiOrientationPortrait;
       
  6170             }
       
  6171         default:
       
  6172             {
       
  6173             return CAknAppUiBase::EAppUiOrientationUnspecified;
       
  6174             }
       
  6175         }
       
  6176     }
       
  6177 
       
  6178 // ---------------------------------------------------------------------------
       
  6179 // CCamAppUi::LayoutStateToOrientation
       
  6180 // Returns the camera orientation based on the layout state set by the phone
       
  6181 // ---------------------------------------------------------------------------
       
  6182 //
       
  6183 TCamOrientation CCamAppUi::LayoutStateToOrientation( TInt aLayoutState )
       
  6184     {
       
  6185     TCamOrientation orientation = ECamOrientationDefault;
       
  6186 
       
  6187 #ifdef __WINS__  
       
  6188     switch(aLayoutState)
       
  6189         {
       
  6190         // Emulator numbers
       
  6191         case 2:
       
  6192             orientation = ECamOrientationPortrait;
       
  6193             break;
       
  6194         case 6:
       
  6195             if( iSoftkeyPosition == ECamHandLeft )
       
  6196                 {
       
  6197                 orientation = ECamOrientationCamcorderLeft;
       
  6198                 }
       
  6199             else
       
  6200                 {
       
  6201                 orientation = ECamOrientationCamcorder;
       
  6202                 }
       
  6203             break;
       
  6204             }
       
  6205 #else // !__WINS__  
       
  6206     switch(aLayoutState)
       
  6207         {
       
  6208         // Magic number alert!
       
  6209         // These numbers come from AknPriv.rss, where they are currently hardcoded
       
  6210         case 0:
       
  6211             orientation = ECamOrientationPortrait;
       
  6212             break;
       
  6213         case 1:
       
  6214             if( iSoftkeyPosition == ECamHandLeft )
       
  6215                 {
       
  6216                 orientation = ECamOrientationCamcorderLeft;
       
  6217                 }
       
  6218             else
       
  6219                 {
       
  6220                 orientation = ECamOrientationCamcorder;
       
  6221                 }
       
  6222             break;
       
  6223         case 2:
       
  6224             orientation = ECamOrientationViewMode;
       
  6225             break;
       
  6226         case 3:
       
  6227             orientation = ECamOrientationPortrait;
       
  6228             break;
       
  6229         default:
       
  6230             orientation = ECamOrientationDefault;
       
  6231             break;
       
  6232         }
       
  6233 #endif // __WINS__
       
  6234 
       
  6235     return orientation;
       
  6236     }
       
  6237 
       
  6238 
       
  6239 // ---------------------------------------------------------------------------
       
  6240 // CCamAppUi::ReadCurrentDeviceOrientation
       
  6241 // Returns the camera orientation based on the layout state set by the phone
       
  6242 // ---------------------------------------------------------------------------
       
  6243 //
       
  6244 TCamOrientation CCamAppUi::ReadCurrentDeviceOrientation()
       
  6245     {
       
  6246     PRINT( _L("Camera <> CCamAppUi::ReadCurrentDeviceOrientation") )
       
  6247     return ECamOrientationDefault;
       
  6248     }
       
  6249 
       
  6250 // ---------------------------------------------------------------------------
       
  6251 // CCamAppUi::ActivePalette
       
  6252 // Return handle to Active Palette
       
  6253 // ---------------------------------------------------------------------------
       
  6254 //
       
  6255 MActivePalette2UI* CCamAppUi::ActivePalette() const
       
  6256     {
       
  6257     return iActivePaletteHandler->ActivePalette();
       
  6258     }
       
  6259 
       
  6260 // ---------------------------------------------------------------------------
       
  6261 // CCamAppUi::APHandler
       
  6262 // Returns pointer to Active Palette handler
       
  6263 // ---------------------------------------------------------------------------
       
  6264 //   
       
  6265 CCamActivePaletteHandler* CCamAppUi::APHandler() const
       
  6266     {
       
  6267     return iActivePaletteHandler;
       
  6268     }
       
  6269 
       
  6270 // ---------------------------------------------------------------------------
       
  6271 // CCamAppUi::DrawPreCaptureCourtesyUI
       
  6272 // Returns whether the optional precapture UI should be currently shown
       
  6273 // ---------------------------------------------------------------------------
       
  6274 //
       
  6275 TBool CCamAppUi::DrawPreCaptureCourtesyUI() const
       
  6276   {
       
  6277   if ( CourtesyUiApplies() )
       
  6278     {
       
  6279     return iDrawPreCaptureCourtesyUI;
       
  6280     }
       
  6281   else
       
  6282     {
       
  6283     // Otherwise always draw the UI
       
  6284     return ETrue;
       
  6285     }
       
  6286   }
       
  6287     
       
  6288 // ---------------------------------------------------------------------------
       
  6289 // CCamAppUi::DrawPostCaptureCourtesyUI
       
  6290 // Returns whether the optional postcapture UI should be currently shown
       
  6291 // ---------------------------------------------------------------------------
       
  6292 //
       
  6293 TBool CCamAppUi::DrawPostCaptureCourtesyUI() const
       
  6294     {
       
  6295     if ( CourtesyUiApplies() )
       
  6296         {
       
  6297         return iDrawPostCaptureCourtesyUI;
       
  6298         }
       
  6299     else
       
  6300         {
       
  6301         // Otherwise always draw the UI
       
  6302         return ETrue;
       
  6303         }
       
  6304     }
       
  6305     
       
  6306 // ---------------------------------------------------------------------------
       
  6307 // CCamAppUi::AlwaysDrawPreCaptureCourtesyUI
       
  6308 // Returns whether the optional precapture UI should always be shown
       
  6309 // ---------------------------------------------------------------------------
       
  6310 //
       
  6311 TBool CCamAppUi::AlwaysDrawPreCaptureCourtesyUI() const
       
  6312     {
       
  6313     return iAlwaysDrawPreCaptureCourtesyUI;
       
  6314     }
       
  6315     
       
  6316 // ---------------------------------------------------------------------------
       
  6317 // CCamAppUi::AlwaysDrawPostCaptureCourtesyUI
       
  6318 // Returns whether the optional postcapture UI should always be shown
       
  6319 // ---------------------------------------------------------------------------
       
  6320 //
       
  6321 TBool CCamAppUi::AlwaysDrawPostCaptureCourtesyUI() const
       
  6322     {
       
  6323     return iAlwaysDrawPostCaptureCourtesyUI;
       
  6324     }
       
  6325     
       
  6326 // ---------------------------------------------------------------------------
       
  6327 // CCamAppUi::SetAlwaysDrawPreCaptureCourtesyUI
       
  6328 // Set whether the optional precapture UI should always be shown
       
  6329 // ---------------------------------------------------------------------------
       
  6330 //
       
  6331 void  CCamAppUi::SetAlwaysDrawPreCaptureCourtesyUI( TBool aNewSetting )
       
  6332     {
       
  6333     iAlwaysDrawPreCaptureCourtesyUI = aNewSetting;
       
  6334     
       
  6335     if ( aNewSetting )
       
  6336         {
       
  6337         RaisePreCaptureCourtesyUI(EFalse);
       
  6338         }
       
  6339     else
       
  6340         {
       
  6341         SubmergePreCaptureCourtesyUI();
       
  6342         }
       
  6343     }
       
  6344     
       
  6345 // ---------------------------------------------------------------------------
       
  6346 // CCamAppUi::SetAlwaysDrawPostCaptureCourtesyUI
       
  6347 // Set whether the optional postcapture UI should always be shown
       
  6348 // ---------------------------------------------------------------------------
       
  6349 //
       
  6350 void  CCamAppUi::SetAlwaysDrawPostCaptureCourtesyUI(TBool aNewSetting)
       
  6351     {
       
  6352     iAlwaysDrawPostCaptureCourtesyUI = aNewSetting;
       
  6353 
       
  6354     if ( aNewSetting )
       
  6355         {
       
  6356         RaisePostCaptureCourtesyUI();
       
  6357         }
       
  6358     else
       
  6359         {
       
  6360         SubmergePostCaptureCourtesyUI();
       
  6361         }
       
  6362     }
       
  6363 
       
  6364 // ---------------------------------------------------------------------------
       
  6365 // CCamAppUi::CourtesyTimeout
       
  6366 // Called after 15 seconds of key inactivity
       
  6367 // ---------------------------------------------------------------------------
       
  6368 //
       
  6369 TInt CCamAppUi::CourtesyTimeout( TAny* aPtr )
       
  6370     {
       
  6371     return static_cast<CCamAppUi*>( aPtr )->DoCourtesyTimeout();
       
  6372     }
       
  6373     
       
  6374 // ---------------------------------------------------------------------------
       
  6375 // CCamAppUi::DoCourtesyTimeoutL
       
  6376 // Called after 15 seconds of key inactivity
       
  6377 // ---------------------------------------------------------------------------
       
  6378 //
       
  6379 TInt CCamAppUi::DoCourtesyTimeout()
       
  6380     {
       
  6381     if ( iCourtesyTimerInPreCapture )
       
  6382         {
       
  6383         if ( iController.IsTouchScreenSupported() )
       
  6384             {
       
  6385             CAknToolbar* toolbar = CurrentFixedToolbar();
       
  6386             if ( toolbar )
       
  6387                 {
       
  6388                 CAknToolbarExtension* toolbarextension =
       
  6389                     toolbar->ToolbarExtension();
       
  6390                 if ( toolbarextension && toolbarextension->IsShown() )
       
  6391                     {
       
  6392                     // Do not hide courtesy UI when toolbar extension is open
       
  6393 
       
  6394                     return EFalse;
       
  6395                     }
       
  6396                 }
       
  6397             }
       
  6398         iDrawPreCaptureCourtesyUI = EFalse;
       
  6399         SubmergePreCaptureCourtesyUI();
       
  6400         }
       
  6401     
       
  6402     iCourtesyTimer->Cancel();
       
  6403 
       
  6404     return EFalse;
       
  6405     }
       
  6406     
       
  6407 // ---------------------------------------------------------------------------
       
  6408 // CCamAppUi::CheckCourtesyKeyEventL
       
  6409 // Check whether the current key event should raise the optional UI
       
  6410 // ---------------------------------------------------------------------------
       
  6411 //
       
  6412 TKeyResponse CCamAppUi::CheckCourtesyKeyEventL( 
       
  6413             const TKeyEvent aKeyEvent, 
       
  6414             TEventCode aType, 
       
  6415             TBool aInPreCapture )
       
  6416     {
       
  6417     PRINT(_L("Camera => CheckCourtesyKeyEventL"))
       
  6418 
       
  6419     TKeyResponse retVal = EKeyWasNotConsumed;
       
  6420 
       
  6421     if ( CourtesyUiApplies() )
       
  6422         {
       
  6423         // Always reset the timer on any key event, if appropriate
       
  6424         if(    (   (  aInPreCapture && !iAlwaysDrawPreCaptureCourtesyUI  )
       
  6425                ||  ( !aInPreCapture && !iAlwaysDrawPostCaptureCourtesyUI )
       
  6426                )
       
  6427            &&
       
  6428                (   ( aInPreCapture && iDrawPreCaptureCourtesyUI  )
       
  6429                ||  (!aInPreCapture && iDrawPostCaptureCourtesyUI )
       
  6430                )
       
  6431           )
       
  6432             {
       
  6433             iCourtesyTimer->Cancel();
       
  6434             iCourtesyTimer->StartTimer();
       
  6435             iCourtesyTimerInPreCapture = aInPreCapture;
       
  6436             }
       
  6437         // Here we check if the LSK key is pressed by using the scan code
       
  6438         // We do this, to show the active tool bar when LSK is pressed when 
       
  6439         // the AP tool bar is hidden AND Pressing "RSK" shall have to return
       
  6440         // to PreCaptureView (Image/Video mode)
       
  6441         // LSK  --> Left Softkey 
       
  6442         // RSK  --> Right Softkey        
       
  6443         if ( aType == EEventKeyDown && 
       
  6444              aKeyEvent.iScanCode == EStdKeyDevice0 )
       
  6445         	{
       
  6446         	iLeftSoftKeyPressed = ETrue;
       
  6447         	}
       
  6448         else
       
  6449         	{
       
  6450         	iLeftSoftKeyPressed = EFalse;
       
  6451         	}
       
  6452  
       
  6453         if ( iController.UiConfigManagerPtr() && 
       
  6454              !iController.UiConfigManagerPtr()->IsLocationSupported() )
       
  6455             {
       
  6456 			if ( aType == EEventKey && 
       
  6457            	  	aKeyEvent.iScanCode == EStdKeyNo )
       
  6458         		{
       
  6459         		iEndKeyPressed = ETrue;
       
  6460         		}
       
  6461         	else
       
  6462         		{
       
  6463         		iEndKeyPressed = EFalse;
       
  6464         		}
       
  6465             }
       
  6466 
       
  6467         const TCamCaptureOperation operation( iController.CurrentOperation() );        
       
  6468         if ( aType == EEventKey )
       
  6469             {
       
  6470             if ( EStdKeyRightArrow == aKeyEvent.iScanCode && !iController.IsTouchScreenSupported() )
       
  6471                  {
       
  6472                  if( aInPreCapture )
       
  6473                      { 
       
  6474                      // during sequence capturing, Navi-Right is inactive to affect CourtesyUI
       
  6475                      if ( !( IsBurstEnabled() && ( ECamCapturing == operation || ECamCompleting == operation ) )  )
       
  6476                          {
       
  6477                          iDrawPreCaptureCourtesyUI = EFalse;	
       
  6478                          if ( !IsSecondCameraEnabled() )
       
  6479                              {                         
       
  6480                              SubmergePreCaptureCourtesyUI();
       
  6481                              }
       
  6482                          else if ( !IsEmbedded() )
       
  6483                              {
       
  6484                              SetActivePaletteVisibility( EFalse );
       
  6485                              if ( ECamControllerVideo == iMode )
       
  6486                                  {
       
  6487                                  SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__RECORD_TXT );
       
  6488                                  }
       
  6489                              else
       
  6490                                  {
       
  6491                                  SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CAPTURE_TXT );
       
  6492                                  }
       
  6493                              }
       
  6494                          }
       
  6495                      }
       
  6496                  else
       
  6497                      {
       
  6498                      iDrawPostCaptureCourtesyUI = EFalse;	
       
  6499                      if ( !IsSecondCameraEnabled() )
       
  6500                          {                                              
       
  6501                          SubmergePostCaptureCourtesyUI();
       
  6502                          }
       
  6503                      else
       
  6504                          {
       
  6505                          SetActivePaletteVisibility( EFalse );
       
  6506                          }
       
  6507                      }
       
  6508                  return EKeyWasConsumed;
       
  6509                  }
       
  6510                  
       
  6511              else if ( (  EStdKeyLeftArrow == aKeyEvent.iScanCode
       
  6512                      || (!aInPreCapture && EStdKeyDevice3 == aKeyEvent.iScanCode && !IsToolBarVisible() ) ) 
       
  6513                      && !iController.IsTouchScreenSupported() )
       
  6514                  {
       
  6515                  iRotatedKeyEvent = ETrue;
       
  6516                  if( aInPreCapture )
       
  6517                      {
       
  6518                      // during sequence capturing, Navi-Left is inactive to affect CourtesyUI
       
  6519                      if ( !( IsBurstEnabled() && ( ECamCapturing == operation || ECamCompleting == operation ) )  )
       
  6520                          {
       
  6521                          iDrawPreCaptureCourtesyUI = ETrue;
       
  6522                          RaisePreCaptureCourtesyUI(EFalse);
       
  6523                          
       
  6524                          if ( /*IsSecondCameraEnabled() 
       
  6525                                 &&*/ !IsEmbedded() )
       
  6526                              {
       
  6527                              if ( ECamControllerVideo == iMode )
       
  6528                                  {
       
  6529                              IsSecondCameraEnabled()?SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__RECORD_SECONDARY ):
       
  6530                              SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__RECORD );
       
  6531                                  }
       
  6532                              else
       
  6533                                  {
       
  6534                                   IsSecondCameraEnabled()?SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CAPTURE_SECONDARY ):
       
  6535                                                           SetSoftKeysL( R_CAM_SOFTKEYS_OPTIONS_EXIT__CAPTURE ); 
       
  6536                                  }
       
  6537                              }
       
  6538                          }
       
  6539                      }
       
  6540                  else
       
  6541                      {
       
  6542                      iDrawPostCaptureCourtesyUI = ETrue;
       
  6543                      RaisePostCaptureCourtesyUI();
       
  6544                      }
       
  6545                  return EKeyWasConsumed;
       
  6546                  }
       
  6547             // Only check if the user has turned the UI off
       
  6548             if(   (  aInPreCapture && !iAlwaysDrawPreCaptureCourtesyUI )
       
  6549                || ( !aInPreCapture && !iAlwaysDrawPostCaptureCourtesyUI ))
       
  6550                 {
       
  6551                 // Decide whether to turn the UI back on        
       
  6552                 if(    ( aInPreCapture && !iDrawPreCaptureCourtesyUI)
       
  6553                     || (!aInPreCapture && !iDrawPostCaptureCourtesyUI))
       
  6554                     {
       
  6555                     if (   aKeyEvent.iScanCode == EStdKeyUpArrow 
       
  6556                         || aKeyEvent.iScanCode ==  EStdKeyDownArrow
       
  6557                         || aKeyEvent.iScanCode ==  EStdKeyDevice3 
       
  6558                         // Navikey select
       
  6559                        )
       
  6560                         {
       
  6561                         if ( aInPreCapture )
       
  6562                             {
       
  6563                             RaisePreCaptureCourtesyUI(EFalse);
       
  6564                             }
       
  6565                         else
       
  6566                             {
       
  6567                             RaisePostCaptureCourtesyUI();
       
  6568                             }
       
  6569                         retVal = EKeyWasConsumed;
       
  6570                         }
       
  6571                     }
       
  6572 #ifndef __WINS__
       
  6573                 RArray <TInt> halfCaptureKeys;
       
  6574                 CleanupClosePushL( halfCaptureKeys );
       
  6575 
       
  6576                 // now get half key press code to register
       
  6577                 if ( iController.UiConfigManagerPtr() )
       
  6578                     {
       
  6579                     iController.UiConfigManagerPtr()->
       
  6580                                 SupportedPrimaryCameraAutoFocusKeyL( halfCaptureKeys );
       
  6581                     }
       
  6582                 if ( halfCaptureKeys.Count() > 0 )
       
  6583                     {
       
  6584                     if ( aInPreCapture && aKeyEvent.iScanCode 
       
  6585                         == halfCaptureKeys[0] )
       
  6586                         {
       
  6587                         SubmergePreCaptureCourtesyUI();
       
  6588                         retVal = EKeyWasConsumed;
       
  6589                         }                    
       
  6590                     }
       
  6591                 CleanupStack::PopAndDestroy( &halfCaptureKeys );
       
  6592 #else
       
  6593                 if ( aInPreCapture && aKeyEvent.iScanCode 
       
  6594                     == EProductKeyCaptureHalf )
       
  6595                     {
       
  6596                     SubmergePreCaptureCourtesyUI();
       
  6597                     retVal = EKeyWasConsumed;
       
  6598                     }
       
  6599 #endif 
       
  6600                 }
       
  6601             }
       
  6602         }
       
  6603     PRINT(_L("Camera <= CheckCourtesyKeyEvent"))
       
  6604     
       
  6605     return retVal;
       
  6606     }
       
  6607     
       
  6608 // ---------------------------------------------------------------------------
       
  6609 // CCamAppUi::RaisePreCaptureCourtesyUI
       
  6610 // Shows the optional precapture UI
       
  6611 // ---------------------------------------------------------------------------
       
  6612 //
       
  6613 void CCamAppUi::RaisePreCaptureCourtesyUI(TBool aShowZoomBar)
       
  6614     {
       
  6615     PRINT1(_L("Camera => CCamAppUi::RaisePreCaptureCourtesyUI \
       
  6616          aShowZoomBar = %d"), aShowZoomBar);
       
  6617     
       
  6618     if ( CourtesyUiApplies() && iDrawPreCaptureCourtesyUI )
       
  6619         {
       
  6620 
       
  6621         iDrawPreCaptureCourtesyUI = ETrue;
       
  6622         
       
  6623         if ( iCamZoomPane && aShowZoomBar && !iCamZoomPane->IsZoomAtMinimum() )  
       
  6624             {
       
  6625             PRINT(_L("Camera == CCamAppUi::RaisePreCaptureCourtesyUI \
       
  6626                 Showing zoom pane"));
       
  6627             
       
  6628             CCamViewBase* view = NULL;
       
  6629             
       
  6630             if ( iMode == ECamControllerVideo )
       
  6631                 {
       
  6632                 view = iVideoCaptureView;
       
  6633                 }
       
  6634             else
       
  6635                 {
       
  6636                 view = iStillCaptureView;
       
  6637                 }
       
  6638             
       
  6639             if ( view )
       
  6640                 {
       
  6641                 CCamContainerBase* container = view->Container();
       
  6642                 
       
  6643                 if ( container )
       
  6644                     {
       
  6645                     container->ShowZoomPaneWithTimer();
       
  6646                     }
       
  6647                 }
       
  6648             }
       
  6649         else
       
  6650             {
       
  6651             if ( iZoomPaneShown && iRotatedKeyEvent )
       
  6652                 {
       
  6653                 HideZoomPane(ETrue);
       
  6654                 iRotatedKeyEvent = EFalse;
       
  6655                 }
       
  6656             }
       
  6657         PRINT(_L("Camera == CCamAppUi::RaisePreCaptureCourtesyUI Showing AP"));
       
  6658         SetActivePaletteVisibility( ETrue );
       
  6659         
       
  6660         TUid settingsPluginUid = KNullUid;
       
  6661 
       
  6662   		  if ( iPlugin )
       
  6663     		    {
       
  6664     		    settingsPluginUid = iPlugin->Id();  
       
  6665     		    }
       
  6666 
       
  6667         if ( iView )
       
  6668             {
       
  6669             const TUid uid1( iView->Id() );
       
  6670             const TInt uid( uid1.iUid );          
       
  6671 
       
  6672         if( !iController.InVideocallOrRinging() &&
       
  6673           ( ECamViewIdStillPreCapture  == uid ||
       
  6674             ECamViewIdStillPostCapture == uid || 
       
  6675             ECamViewIdVideoPreCapture  == uid || 
       
  6676             ECamViewIdVideoPostCapture == uid ||
       
  6677             ECamViewIdBurstThumbnail   == uid )
       
  6678           )
       
  6679                 {
       
  6680                 TRAP_IGNORE( static_cast<CCamViewBase*>
       
  6681                      ( iView )->UnsetCourtesySoftKeysL() );    
       
  6682                 }
       
  6683             }
       
  6684             
       
  6685         TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));
       
  6686             
       
  6687         iCourtesyTimerInPreCapture = ETrue;
       
  6688         
       
  6689         if ( iCourtesyTimer )
       
  6690             {
       
  6691             iCourtesyTimer->Cancel();
       
  6692             
       
  6693             if ( !iAlwaysDrawPreCaptureCourtesyUI )
       
  6694                 {
       
  6695                 iCourtesyTimer->StartTimer();
       
  6696                 }
       
  6697             }
       
  6698         }
       
  6699     PRINT(_L("Camera <= CCamAppUi::RaisePreCaptureCourtesyUI"))
       
  6700     }
       
  6701     
       
  6702 // ---------------------------------------------------------------------------
       
  6703 // CCamAppUi::RaisePostCaptureCourtesyUI
       
  6704 // Shows the optional postcapture UI
       
  6705 // ---------------------------------------------------------------------------
       
  6706 //
       
  6707 void CCamAppUi::RaisePostCaptureCourtesyUI()
       
  6708     {
       
  6709     PRINT(_L("Camera => CCamAppUi::RaisePostCaptureCourtesyUI"))
       
  6710     if ( CourtesyUiApplies() )
       
  6711         {
       
  6712         iDrawPostCaptureCourtesyUI = ETrue;
       
  6713 
       
  6714         SetActivePaletteVisibility( ETrue );
       
  6715 
       
  6716         if ( iView )
       
  6717             {
       
  6718             TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6719                  (iView)->UnsetCourtesySoftKeysL());
       
  6720             }
       
  6721             
       
  6722         TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));
       
  6723             
       
  6724         iCourtesyTimerInPreCapture = EFalse;
       
  6725         
       
  6726         }
       
  6727     PRINT(_L("Camera <= CCamAppUi::RaisePostCaptureCourtesyUI"))
       
  6728     }
       
  6729 
       
  6730 // ---------------------------------------------------------------------------
       
  6731 // CCamAppUi::SubmergePreCaptureCourtesyUI
       
  6732 // Hides the optional precapture UI
       
  6733 // ---------------------------------------------------------------------------
       
  6734 //
       
  6735 void CCamAppUi::SubmergePreCaptureCourtesyUI()
       
  6736     {
       
  6737     PRINT(_L("Camera => CCamAppUi::SubmergePreCaptureCourtesyUI"))
       
  6738 
       
  6739     const TCamCaptureOperation operation( iController.CurrentOperation() );
       
  6740 
       
  6741 
       
  6742     
       
  6743     if ( ( CourtesyUiApplies() && !iDrawPreCaptureCourtesyUI
       
  6744         && !SelfTimerEnabled() 
       
  6745         && ECamViewStatePreCapture == iViewState )
       
  6746            // and if we are burst capturing 
       
  6747            // then do not remove the cancel softkey
       
  6748            && !( IsBurstEnabled() 
       
  6749               && (ECamCapturing  == operation
       
  6750                 ||ECamCompleting == operation ) ) )
       
  6751         {
       
  6752         if ( FullScreenViewfinderEnabled() )
       
  6753             {
       
  6754             // Don't submerge if we're capturing time-lapse photos
       
  6755             if ( !(ECamImageCaptureTimeLapse == CurrentBurstMode()
       
  6756                 && iController.SequenceCaptureInProgress()) )
       
  6757                 {
       
  6758                 
       
  6759                 if ( ECamControllerVideo == iMode )
       
  6760                 	{
       
  6761 
       
  6762 	                SetActivePaletteVisibility( EFalse );
       
  6763 	                
       
  6764 	                if ( iController.IsTouchScreenSupported() )
       
  6765 	                    {
       
  6766 	                    // Enable fixed toolbar
       
  6767 	                    CAknToolbar* toolbar = CurrentFixedToolbar();
       
  6768 	                    if ( toolbar )
       
  6769 	                        {
       
  6770 	                        toolbar->SetToolbarVisibility( EFalse );
       
  6771 	                        }
       
  6772 	                    }
       
  6773 	
       
  6774 	                if ( iView )
       
  6775 	                    {
       
  6776 	                    if(!iController.IsTouchScreenSupported())
       
  6777 	                        {
       
  6778 	                    TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6779 	                        (iView)->SetCourtesySoftKeysL());
       
  6780 	                        }
       
  6781 	                    else
       
  6782 	                        {
       
  6783 	                        TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6784 	                            (iView)->UnsetCourtesySoftKeysL());
       
  6785 	                        }
       
  6786 	                    }
       
  6787 
       
  6788                 	} // end if ( iMode == ECamControllerVideo )
       
  6789 		        else
       
  6790 		        	{
       
  6791 		        	// in still mode toolbar and softkeys
       
  6792 		        	// are not to be hidden as part of courtesy ui
       
  6793 		        	// imode: ECamControllerIdle, ECamControllerImage,
       
  6794 		        	// or ECamControllerShutdown
       
  6795 
       
  6796 		        	SetActivePaletteVisibility( EFalse );
       
  6797 		        	
       
  6798 	                if ( iView )
       
  6799 	                    {
       
  6800 	                    if(!iController.IsTouchScreenSupported())
       
  6801 	                        {
       
  6802 	                        TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6803 	                            (iView)->SetCourtesySoftKeysL());
       
  6804 	                        }
       
  6805 	                    else
       
  6806 	                        {
       
  6807 	                        TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6808 	                             (iView)->UnsetCourtesySoftKeysL());
       
  6809 	                        }
       
  6810 	                    }
       
  6811 		        	
       
  6812 		        	}
       
  6813                 
       
  6814                 TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));	
       
  6815                 }
       
  6816 	            
       
  6817             } // if ( FullScreenViewfinderEnabled() 
       
  6818         }               
       
  6819     PRINT(_L("Camera <= CCamAppUi::SubmergePreCaptureCourtesyUI"))
       
  6820     }
       
  6821     
       
  6822     
       
  6823 // ---------------------------------------------------------------------------
       
  6824 // CCamAppUi::SubmergePostCaptureCourtesyUI
       
  6825 // Hides the optional postcapture UI
       
  6826 // ---------------------------------------------------------------------------
       
  6827 //
       
  6828 void CCamAppUi::SubmergePostCaptureCourtesyUI()
       
  6829     {
       
  6830     PRINT(_L("Camera => CCamAppUi::SubmergePostCaptureCourtesyUI"))
       
  6831     if ( CourtesyUiApplies() 
       
  6832 
       
  6833          && ECamViewStatePostCapture == iViewState )
       
  6834         {
       
  6835         iDrawPostCaptureCourtesyUI = EFalse;
       
  6836         
       
  6837         SetActivePaletteVisibility( EFalse );
       
  6838 
       
  6839         if ( iView )
       
  6840             {
       
  6841             TRAP_IGNORE(static_cast<CCamViewBase*>
       
  6842                  (iView)->SetCourtesySoftKeysL());
       
  6843             }
       
  6844 
       
  6845     TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));
       
  6846         }
       
  6847     PRINT(_L("Camera <= CCamAppUi::SubmergePostCaptureCourtesyUI"))
       
  6848     }
       
  6849 
       
  6850 // ---------------------------------------------------------------------------
       
  6851 // CCamAppUi::ShowZoomPane
       
  6852 // Needed to show or update the zoom pane in direct viewfinder mode, 
       
  6853 // or where the active toolbar is used.
       
  6854 // ---------------------------------------------------------------------------
       
  6855 //
       
  6856 void CCamAppUi::ShowZoomPane(TBool aRedraw)
       
  6857     {
       
  6858     PRINT( _L("Camera => CCamAppUi::ShowZoomPane" ))
       
  6859     iZoomPaneShown = ETrue;
       
  6860     
       
  6861   if ( aRedraw && IsDirectViewfinderActive() )
       
  6862         {
       
  6863         TRAP_IGNORE(HandleCommandL(ECamCmdRedrawScreen));
       
  6864         }
       
  6865   PRINT( _L("Camera <= CCamAppUi::ShowZoomPane" ))
       
  6866     }
       
  6867     
       
  6868 // ---------------------------------------------------------------------------
       
  6869 // CCamAppUi::HideZoomPane
       
  6870 // Needed to hide the zoom pane in direct viewfinder mode,
       
  6871 // or where the active toolbar is used.
       
  6872 // ---------------------------------------------------------------------------
       
  6873 //
       
  6874 void CCamAppUi::HideZoomPane( TBool aRedraw )
       
  6875     {
       
  6876     PRINT( _L("Camera => CCamAppUi::HideZoomPane" ))
       
  6877     iZoomPaneShown = EFalse;
       
  6878     
       
  6879     if ( iDrawPreCaptureCourtesyUI && iController.IsViewFinding() )
       
  6880         {
       
  6881         if ( iViewState == ECamViewStatePreCapture )
       
  6882             {
       
  6883             SetActivePaletteVisibility( ETrue );
       
  6884             }
       
  6885         }
       
  6886         
       
  6887   if ( aRedraw && IsDirectViewfinderActive() )
       
  6888         {
       
  6889         TRAP_IGNORE( HandleCommandL(ECamCmdRedrawScreen ) );
       
  6890         }
       
  6891   PRINT( _L("Camera <= CCamAppUi::HideZoomPane" ))
       
  6892     }
       
  6893 
       
  6894 // ---------------------------------------------------------------------------
       
  6895 // CCamAppUi::SetActivePaletteVisibility
       
  6896 // Displays or hides the active palette, depending on some inbuilt restraints
       
  6897 // ---------------------------------------------------------------------------
       
  6898 //
       
  6899 
       
  6900 void CCamAppUi::SetActivePaletteVisibility( TBool aShown )
       
  6901   {
       
  6902   PRINT1( _L("Camera => CCamAppUi::SetActivePaletteVisibility %d" ), aShown )
       
  6903 
       
  6904   if ( !iController.IsTouchScreenSupported() )
       
  6905       {
       
  6906       if ( ECamOrientationCamcorder     == iCamOrientation 
       
  6907         || ECamOrientationCamcorderLeft == iCamOrientation
       
  6908         || ECamOrientationPortrait == iCamOrientation )
       
  6909         {
       
  6910         TCamCaptureOperation operation = iController.CurrentOperation();
       
  6911      
       
  6912         // Does the current video mode prevent showing.
       
  6913         //    
       
  6914         TBool videoOperationPrevents = 
       
  6915              ( ECamControllerVideo == iMode )
       
  6916           && ( ECamCapturing == operation || ECamPaused == operation );
       
  6917 
       
  6918         TBool imageOperationPrevents = 
       
  6919               ( ECamControllerImage == iMode )
       
  6920            && ( ECamCapturing == operation || ECamCompleting == operation
       
  6921                 || ECamFocusing == operation || ECamFocused == operation
       
  6922                 || ECamFocusFailed == operation );
       
  6923 
       
  6924         if (  (!aShown )
       
  6925 
       
  6926            || ( aShown && !iPreventActivePaletteDisplay
       
  6927                        && !TimeLapseSliderShown()
       
  6928                        && ( iViewState == ECamViewStatePostCapture 
       
  6929                             || FullScreenViewfinderEnabled()
       
  6930                             || IsSecondCameraEnabled() )
       
  6931                        && !videoOperationPrevents
       
  6932                        && !imageOperationPrevents
       
  6933                        && ((iDrawPreCaptureCourtesyUI && iViewState == ECamViewStatePreCapture) 
       
  6934                        || (iDrawPostCaptureCourtesyUI && iViewState == ECamViewStatePostCapture) ))
       
  6935            )
       
  6936           {
       
  6937           if ( iActivePaletteHandler )
       
  6938             {
       
  6939             PRINT1(_L("Precapture mode is %d"),iPreCaptureMode)                
       
  6940             PRINT(_L("Setting Active Palette Visibility"))
       
  6941             iActivePaletteHandler->SetVisibility( aShown );
       
  6942             if ( ( !IsEmbedded() && IsSecondCameraEnabled() ) 
       
  6943                     || !IsSecondCameraEnabled() )
       
  6944                 {
       
  6945                 iToolbarVisibility = aShown;
       
  6946                 }
       
  6947             else if ( IsEmbedded() && IsSecondCameraEnabled() ) 
       
  6948                 {
       
  6949                 iToolbarVisibility = EFalse;
       
  6950                 }
       
  6951             }
       
  6952           }
       
  6953         }
       
  6954       }
       
  6955   PRINT( _L("Camera <= CCamAppUi::SetActivePaletteVisibility" ))
       
  6956   }
       
  6957 
       
  6958 
       
  6959 // ---------------------------------------------------------------------------
       
  6960 // CCamAppUi::IsDirectViewfinderActive
       
  6961 // Detects whether the direct viewfinder is in use or not
       
  6962 // ---------------------------------------------------------------------------
       
  6963 //
       
  6964 TBool CCamAppUi::IsDirectViewfinderActive() 
       
  6965     {
       
  6966     if ( iController.UiConfigManagerPtr() && 
       
  6967        ( ( iDSASupported  && iCamOrientation == ECamOrientationCamcorder  || 
       
  6968            iCamOrientation == ECamOrientationCamcorderLeft ) || 
       
  6969          ( iController.IsDirectScreenVFSupported( EFalse ) &&
       
  6970            iCamOrientation == ECamOrientationPortrait ) ) && 
       
  6971            !( IsBurstEnabled() && iController.SequenceCaptureInProgress() ) )
       
  6972         {
       
  6973         return ETrue;
       
  6974         }
       
  6975     return EFalse;
       
  6976     }
       
  6977     
       
  6978 // ---------------------------------------------------------------------------
       
  6979 // CCamAppUi::UpdateNaviModelsL
       
  6980 // Called to set the correct navicounter / naviprogress controls to "active"
       
  6981 // ---------------------------------------------------------------------------
       
  6982 //
       
  6983 void CCamAppUi::UpdateNaviModelsL( const TBool aUpdateNavi )
       
  6984     {
       
  6985     iNaviCounterControl->SetActiveL( EFalse );
       
  6986     iNaviPaneCounterControl->SetActiveL( EFalse );
       
  6987     iNaviProgressBarControl->SetActiveL( EFalse );
       
  6988     iNaviPaneProgressBarControl->SetActiveL( EFalse );
       
  6989     if ( !aUpdateNavi )
       
  6990         {
       
  6991         // We are immediately closing the app or in Pretend Exit
       
  6992         // No need to update NaviPane
       
  6993         return;
       
  6994         }
       
  6995     else if ( ECamOrientationCamcorder == iCamOrientation 
       
  6996         || ECamOrientationCamcorderLeft == iCamOrientation
       
  6997         || ECamOrientationPortrait == iCamOrientation )
       
  6998         {
       
  6999         iNaviCounterControl->SetExtentToWholeScreen();
       
  7000         iNaviCounterControl->SetActiveL( ETrue );
       
  7001         iNaviProgressBarControl->SetExtentToWholeScreen();
       
  7002         iNaviProgressBarControl->SetActiveL( ETrue );
       
  7003         }
       
  7004     else
       
  7005         {
       
  7006         iNaviPaneCounterControl->SetActiveL( ETrue );
       
  7007         iNaviPaneProgressBarControl->SetActiveL( ETrue );
       
  7008         }
       
  7009     }
       
  7010     
       
  7011 // ---------------------------------------------------------------------------
       
  7012 // CCamAppUi::AppController
       
  7013 // Returns the app controller
       
  7014 // ---------------------------------------------------------------------------
       
  7015 //
       
  7016 MCamAppController& CCamAppUi::AppController()
       
  7017     {
       
  7018     return iController;
       
  7019     }
       
  7020 
       
  7021 // ---------------------------------------------------------
       
  7022 // CCamAppUi::ForegroundAppIsPhoneApp
       
  7023 // Whether or not the phone app is in the foreground
       
  7024 // ---------------------------------------------------------
       
  7025 //
       
  7026 TBool CCamAppUi::ForegroundAppIsPhoneApp() const
       
  7027     {
       
  7028     TBool phoneInForeground = EFalse;
       
  7029     // Gets the window group id of the app coming in foreground
       
  7030     TInt windowGroupId = iCoeEnv->WsSession().GetFocusWindowGroup();
       
  7031     if ( windowGroupId == iPhoneAppWindowGroupId )
       
  7032         {
       
  7033         phoneInForeground = ETrue;
       
  7034         }
       
  7035     return phoneInForeground;         
       
  7036     }    
       
  7037    
       
  7038 // ---------------------------------------------------------------------------
       
  7039 // CCamAppUi::SwitchStillCaptureModeL
       
  7040 // Change the still capture mode
       
  7041 // ---------------------------------------------------------------------------
       
  7042 //    
       
  7043 void 
       
  7044 CCamAppUi::SwitchStillCaptureModeL( TCamImageCaptureMode aImageMode, 
       
  7045                                     TBool                aReprepare,
       
  7046                                     TBool                aUpdateUi /*=ETrue*/)
       
  7047   {
       
  7048   PRINT( _L( "Camera => CCamAppUi::SwitchStillCaptureModeL" ) )
       
  7049 
       
  7050   iTargetImageMode = aImageMode;   
       
  7051 
       
  7052   if ( iController.UiConfigManagerPtr()->IsXenonFlashSupported() )
       
  7053       {
       
  7054       switch( iTargetImageMode )
       
  7055         {
       
  7056         case ECamImageCaptureSingle:
       
  7057         case ECamImageCaptureTimeLapse:
       
  7058           {
       
  7059           // Switching from burst mode to single/timelapse mode. 
       
  7060           // Restore previous original flash setting.
       
  7061           iController.RestoreFlashMode();
       
  7062           break;
       
  7063           }
       
  7064         case ECamImageCaptureBurst:
       
  7065           {
       
  7066           if( iImageMode != iTargetImageMode )
       
  7067             {
       
  7068             // Switching from single/timelapse capture to burst mode. 
       
  7069             // Save current flash mode, and disable flash.  
       
  7070             iController.SaveFlashMode();
       
  7071             }           
       
  7072           iController.SetIntegerSettingValueL( ECamSettingItemDynamicPhotoFlash,
       
  7073               ECamFlashOff );
       
  7074           break;
       
  7075           }
       
  7076         }
       
  7077     }
       
  7078  
       
  7079   TBool burstEnabled = ( ECamImageCaptureBurst     == aImageMode 
       
  7080                       || ECamImageCaptureTimeLapse == aImageMode );
       
  7081       
       
  7082   if ( iController.TimeLapseSupported() )
       
  7083     {
       
  7084     // if burst has been disabled
       
  7085     // then make sure the timelapse interval has been
       
  7086     // set back to 0 in the controller.    
       
  7087     if ( !burstEnabled )
       
  7088       {
       
  7089       iController.SetTimeLapseInterval( TInt64(0) );
       
  7090       }
       
  7091     }
       
  7092 
       
  7093   if ( iImageMode != iTargetImageMode )    
       
  7094     {    
       
  7095     // Inform any observers that burst mode has been changed
       
  7096     TInt count = iBurstModeObservers.Count();
       
  7097     TInt i;
       
  7098     for ( i = 0; i < count; i++ )
       
  7099       {
       
  7100       iBurstModeObservers[i]->BurstModeActiveL( burstEnabled, aReprepare );
       
  7101       }
       
  7102     }
       
  7103     
       
  7104   if( aUpdateUi )
       
  7105     {
       
  7106     TrySwitchViewL(); 
       
  7107     }
       
  7108   
       
  7109   iController.BurstModeActiveL( burstEnabled, aReprepare );
       
  7110      
       
  7111   if( aUpdateUi )
       
  7112     {
       
  7113     iNaviCounterModel->SetCaptureModeL( iMode, iImageMode );   
       
  7114 
       
  7115     if ( aReprepare )
       
  7116       {
       
  7117       PRINT( _L( "Camera <> CCamAppUi::SwitchStillCaptureModeL: update AP.." ))
       
  7118       iActivePaletteHandler->UpdateActivePaletteL();    
       
  7119       }
       
  7120     }
       
  7121   PRINT( _L("Camera <= CCamAppUi::SwitchStillCaptureModeL") )
       
  7122   }
       
  7123     
       
  7124 #if !defined(__WINSCW__)
       
  7125 // ---------------------------------------------------------------------------
       
  7126 // CCamAppUi::RegisterCaptureKeysL
       
  7127 // Register to capture half and full shutter press key events
       
  7128 // ---------------------------------------------------------------------------
       
  7129 // 
       
  7130 void CCamAppUi::RegisterCaptureKeysL()
       
  7131   {
       
  7132   RArray<TInt> captureKeys;
       
  7133   CleanupClosePushL( captureKeys );
       
  7134   
       
  7135   if ( iController.UiConfigManagerPtr() )
       
  7136       {
       
  7137       iController.UiConfigManagerPtr()->
       
  7138            SupportedPrimaryCameraCaptureKeyL( captureKeys );
       
  7139       }
       
  7140 
       
  7141   if( iCameraKeyHandle == 0 )
       
  7142     {
       
  7143   	iCameraKeyHandle = iCoeEnv->RootWin().CaptureKey( EKeyCamera, 0, 0 );
       
  7144     }
       
  7145   
       
  7146   if( iFullShutterUpDownHandle == 0 )
       
  7147     {
       
  7148     if ( captureKeys.Count() > 0 )
       
  7149         {
       
  7150         //EProductKeyCapture
       
  7151         iFullShutterUpDownHandle = iCoeEnv->
       
  7152             RootWin().CaptureKeyUpAndDowns( captureKeys[0] , 0, 0 );        
       
  7153         }
       
  7154 
       
  7155     }
       
  7156   
       
  7157   if( iFullShutterPressHandle == 0 )
       
  7158     {
       
  7159     if ( captureKeys.Count() > 0 )
       
  7160         {    
       
  7161         iFullShutterPressHandle = iCoeEnv->
       
  7162             RootWin().CaptureKey( captureKeys[0], 0, 0 );
       
  7163         }
       
  7164     }
       
  7165     
       
  7166   if( iHalfShutterPressHandle == 0 )
       
  7167     {
       
  7168     captureKeys.Reset();
       
  7169     
       
  7170     // now get half key press code to register
       
  7171     if ( iController.UiConfigManagerPtr() )
       
  7172         {
       
  7173         iController.UiConfigManagerPtr()->
       
  7174         SupportedPrimaryCameraAutoFocusKeyL( captureKeys );
       
  7175         }
       
  7176     if ( captureKeys.Count() > 0 )
       
  7177         {
       
  7178         iHalfShutterPressHandle = iCoeEnv->
       
  7179             RootWin().CaptureKey( captureKeys[0], 0, 0 );        
       
  7180         }
       
  7181     }
       
  7182   CleanupStack::PopAndDestroy( &captureKeys );
       
  7183   }
       
  7184     
       
  7185 // ---------------------------------------------------------------------------
       
  7186 // CCamAppUi::UnRegisterCaptureKeys
       
  7187 // Release capture of half and full shutter press key events
       
  7188 // ---------------------------------------------------------------------------
       
  7189 // 
       
  7190 void CCamAppUi::UnRegisterCaptureKeys()
       
  7191   {
       
  7192   //Since this function can be called from the destructor, we should
       
  7193   //check that iCoeEnv isn't null prior to using it.
       
  7194   if( iCoeEnv )
       
  7195       {
       
  7196       if ( iCameraKeyHandle > 0 )
       
  7197             {
       
  7198             iCoeEnv->RootWin().CancelCaptureKey( iCameraKeyHandle );
       
  7199             iCameraKeyHandle = 0;
       
  7200             }
       
  7201       if ( iFullShutterPressHandle > 0 )
       
  7202             {
       
  7203             iCoeEnv->RootWin().CancelCaptureKey( iFullShutterPressHandle );
       
  7204             iFullShutterPressHandle = 0;
       
  7205             }
       
  7206         if ( iHalfShutterPressHandle > 0 )
       
  7207             {
       
  7208             iCoeEnv->RootWin().CancelCaptureKey( iHalfShutterPressHandle );
       
  7209             iHalfShutterPressHandle = 0;
       
  7210             }
       
  7211             
       
  7212         if ( iFullShutterUpDownHandle > 0 )
       
  7213             {
       
  7214             iCoeEnv->RootWin().CancelCaptureKey( iFullShutterUpDownHandle );
       
  7215             iFullShutterUpDownHandle = 0;
       
  7216             }    
       
  7217       }
       
  7218   }
       
  7219   
       
  7220 #endif
       
  7221 
       
  7222 // ---------------------------------------------------------------------------
       
  7223 // CCamAppUi::SetSoftKeysL
       
  7224 // Sets the softkeys to the specified Resource ID
       
  7225 // ---------------------------------------------------------------------------
       
  7226 //
       
  7227 void CCamAppUi::SetSoftKeysL( TInt aResource )
       
  7228   {
       
  7229   PRINT1( _L("Camera => CCamAppUi::SetSoftKeysL resource:%x"), aResource );
       
  7230   if ( iView )
       
  7231     {
       
  7232     static_cast<CCamViewBase*>(iView)->SetSoftKeysL(aResource);
       
  7233     }
       
  7234   PRINT( _L("Camera <= CCamAppUi::SetSoftKeysL") );
       
  7235   }
       
  7236     
       
  7237 // ---------------------------------------------------------------------------
       
  7238 // CCamAppUi::TimeLapseSliderShown
       
  7239 // Returns whether time lapse slider is currently shown
       
  7240 // ---------------------------------------------------------------------------
       
  7241 //
       
  7242 TBool CCamAppUi::TimeLapseSliderShown() const
       
  7243     {
       
  7244     return ECamPreCapTimeLapseSlider == iPreCaptureMode;    
       
  7245     }     
       
  7246 
       
  7247 // ---------------------------------------------------------------------------
       
  7248 // CCamAppUi::FullScreenViewfinderEnabled
       
  7249 // Returns whether or not the full screen viewfinder is being shown
       
  7250 // ---------------------------------------------------------------------------
       
  7251 //
       
  7252 TBool CCamAppUi::FullScreenViewfinderEnabled() const
       
  7253     {
       
  7254     TBool retVal = EFalse;
       
  7255 
       
  7256     if ( ECamViewStatePreCapture == iViewState
       
  7257         && ( ECamOrientationCamcorder == iCamOrientation
       
  7258             || ECamOrientationCamcorderLeft == iCamOrientation )
       
  7259         && ECamPreCapViewfinder == iPreCaptureMode)
       
  7260         {
       
  7261         retVal = ETrue;
       
  7262         }
       
  7263         
       
  7264     return retVal;        
       
  7265     }
       
  7266 
       
  7267 // ---------------------------------------------------------------------------
       
  7268 // CCamAppUi::SetPreCaptureModeL
       
  7269 // Sets the current pre-capture mode
       
  7270 // ---------------------------------------------------------------------------
       
  7271 //
       
  7272 void CCamAppUi::SetPreCaptureModeL(TCamPreCaptureMode aMode)  
       
  7273     {
       
  7274     PRINT(_L("Camera=>CCamAppUi::SetPreCaptureMode"))
       
  7275     iPreCaptureMode = aMode;
       
  7276 
       
  7277     CCamViewBase* precapView = NULL;
       
  7278     if ( iView == iStillCaptureView ||
       
  7279          iView == iVideoCaptureView )
       
  7280         {
       
  7281         precapView = static_cast<CCamViewBase*>( iView );
       
  7282 		__ASSERT_DEBUG( precapView, CamPanic( ECamPanicNullPointer ));
       
  7283 		}
       
  7284    
       
  7285     if ( ECamPreCapViewfinder == iPreCaptureMode )
       
  7286         {
       
  7287         if ( !( iController.UiConfigManagerPtr() && 
       
  7288                 iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) )
       
  7289             {
       
  7290             RaisePreCaptureCourtesyUI(ETrue);
       
  7291             }
       
  7292         if ( precapView )
       
  7293             {
       
  7294             if ( iView == iStillCaptureView )
       
  7295 	            {
       
  7296 	            // fixed toolbar is used only with touch devices
       
  7297 	            if ( iController.IsTouchScreenSupported() )
       
  7298 	                {
       
  7299                     if ( IsSecondCameraEnabled() )
       
  7300                         {
       
  7301                         TInt resourceId = IsQwerty2ndCamera()? 
       
  7302                                       R_CAM_STILL_PRECAPTURE_TOOLBAR_LANDSCAPE:
       
  7303                                       R_CAM_STILL_PRECAPTURE_TOOLBAR_PORTRAIT; 
       
  7304                         precapView->CreateAndSetToolbarL( resourceId );		
       
  7305                         }
       
  7306                     else
       
  7307                         {
       
  7308                         precapView->CreateAndSetToolbarL( R_CAM_STILL_PRECAPTURE_TOOLBAR ); 
       
  7309                         }
       
  7310                     CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  7311                     fixedToolbar->SetToolbarVisibility( EFalse );
       
  7312 
       
  7313                     if ( !IsSecondCameraEnabled() )
       
  7314                         {
       
  7315                         iStillCaptureView->UpdateToolbarIconsL();
       
  7316                         }
       
  7317 	                
       
  7318 	                fixedToolbar->SetToolbarObserver( iStillCaptureView );
       
  7319 	                SetToolbarVisibility();
       
  7320 
       
  7321 	                // Make sure toolbar extension button has no background
       
  7322 	                CAknButton* extensionButton = static_cast<CAknButton*>(
       
  7323 	                    fixedToolbar->ControlOrNull( ECamCmdToolbarExtension ) );
       
  7324 	                if ( extensionButton )
       
  7325 	                    {
       
  7326 	                    extensionButton->SetButtonFlags(
       
  7327 	                       // Set KAknButtonNoFrame flag for extension buttons      
       
  7328 	                       extensionButton->ButtonFlags() | KAknButtonNoFrame );
       
  7329 	                    }   
       
  7330 	                }
       
  7331     	        }
       
  7332             else if ( iView == iVideoCaptureView )
       
  7333         	    {
       
  7334         	    // fixed toolbar is used only with touch devices
       
  7335         	    if ( iController.IsTouchScreenSupported() )
       
  7336         	        {
       
  7337                     if ( IsSecondCameraEnabled() )
       
  7338                         {
       
  7339                         TInt resourceId = IsQwerty2ndCamera()? 
       
  7340                                       R_CAM_VIDEO_PRECAPTURE_TOOLBAR_LANDSCAPE:
       
  7341                                       R_CAM_VIDEO_PRECAPTURE_TOOLBAR_PORTRAIT; 
       
  7342                         precapView->CreateAndSetToolbarL( resourceId );	
       
  7343                         }
       
  7344                     else
       
  7345                         {
       
  7346                         if(iController.UiConfigManagerPtr()->IsXenonFlashSupported())
       
  7347                             {
       
  7348                             precapView->CreateAndSetToolbarL(R_CAM_VIDEO_PRECAPTURE_TOOLBAR);
       
  7349                             }
       
  7350                         else
       
  7351                             {
       
  7352                             precapView->CreateAndSetToolbarL(R_CAM_VIDEO_PRECAPTURE_TOOLBAR_VIDEOLIGHT);
       
  7353                             }
       
  7354                         }
       
  7355                     CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  7356                     fixedToolbar->SetToolbarVisibility( EFalse );
       
  7357 
       
  7358                     if ( !IsSecondCameraEnabled() )
       
  7359                         {
       
  7360                         iVideoCaptureView->UpdateToolbarIconsL();
       
  7361                         }
       
  7362                     
       
  7363                     fixedToolbar->SetToolbarObserver( iVideoCaptureView );
       
  7364                     SetToolbarVisibility();
       
  7365                        
       
  7366                     // Make sure toolbar extension button has no background
       
  7367                     CAknButton* extensionButton = static_cast<CAknButton*>(
       
  7368                       fixedToolbar->ControlOrNull( ECamCmdToolbarExtension ) );
       
  7369                     if ( extensionButton )
       
  7370                         {
       
  7371                         extensionButton->SetButtonFlags(
       
  7372                         // Set KAknButtonNoFrame flag for extension buttons      
       
  7373                         extensionButton->ButtonFlags() | KAknButtonNoFrame );
       
  7374                         }
       
  7375         	        }
       
  7376         	    }
       
  7377             	
       
  7378             if( !IsSecondCameraEnabled() || IsQwerty2ndCamera() )  
       
  7379                 {
       
  7380                 EikSoftkeyPostingTransparency::MakeTransparent(
       
  7381                         *precapView->ViewCba(), ETrue );
       
  7382                 
       
  7383                 if( iDrawPreCaptureCourtesyUI )
       
  7384                     {
       
  7385                     precapView->ViewCba()->MakeVisible( ETrue );
       
  7386                     }
       
  7387                 }
       
  7388               
       
  7389             }
       
  7390         }
       
  7391     else
       
  7392         {
       
  7393         if ( precapView )
       
  7394             {
       
  7395             precapView->ViewCba()->MakeVisible( ETrue );
       
  7396             // fixed toolbar is used only with touch devices
       
  7397             if ( iController.IsTouchScreenSupported() )
       
  7398                 {
       
  7399                 precapView->CreateAndSetToolbarL( R_CAM_EMPTY_FIXED_TOOLBAR );
       
  7400                 }
       
  7401             EikSoftkeyPostingTransparency::MakeTransparent(
       
  7402                 *precapView->ViewCba(), EFalse );
       
  7403             }
       
  7404         SetActivePaletteVisibility( EFalse );
       
  7405         }
       
  7406 
       
  7407     if ( iViewState != ECamViewStateUserSceneSetup )
       
  7408         {
       
  7409 	    if ( CamUtility::IsNhdDevice() ) 
       
  7410 	        {
       
  7411 	        StatusPane()->MakeVisible( aMode == ECamPreCapStandby || 
       
  7412 	                                   IsSecondCameraEnabled() && 
       
  7413 	                                   !IsQwerty2ndCamera() ||
       
  7414 	                                   SettingsLaunchedFromCamera() ); 
       
  7415 	        }
       
  7416 	    else
       
  7417 	        {
       
  7418 	        // Settings, launched via toolbar, have a visible statuspane in 
       
  7419 	        // Non-touch device 
       
  7420 	        StatusPane()->MakeVisible( !precapView ||
       
  7421 	                                   aMode != ECamPreCapViewfinder &&      
       
  7422 	                                   aMode != ECamPreCapTimeLapseSlider || 
       
  7423 	                                   IsSecondCameraEnabled() ||
       
  7424 	                                   SettingsLaunchedFromCamera() );  
       
  7425 	        }
       
  7426         }
       
  7427 
       
  7428 
       
  7429     PRINT(_L("Camera<=CCamAppUi::SetPreCaptureMode"))        
       
  7430     }
       
  7431     
       
  7432 // ---------------------------------------------------------------------------
       
  7433 // CCamAppUi::SetPreCaptureMode
       
  7434 // Sets the current pre-capture mode
       
  7435 // ---------------------------------------------------------------------------
       
  7436 //
       
  7437 void CCamAppUi::SetPreCaptureMode( TCamPreCaptureMode aMode )  
       
  7438     {
       
  7439     TRAPD(err, SetPreCaptureModeL( aMode ) );
       
  7440     if ( err )
       
  7441         {
       
  7442         PRINT1(_L("Camera<=CCamAppUi::SetPreCaptureModeL Leave=%d"), err)   
       
  7443         }
       
  7444     }
       
  7445 
       
  7446 // ---------------------------------------------------------------------------
       
  7447 // CCamAppUi::ShowPostCaptureView
       
  7448 // Whether to show the post capture view in current mode
       
  7449 // ---------------------------------------------------------------------------
       
  7450 //
       
  7451 TBool CCamAppUi::ShowPostCaptureView() const
       
  7452   {
       
  7453   TInt settingId( ( ECamControllerVideo == iMode )
       
  7454                   ? ECamSettingItemVideoShowCapturedVideo
       
  7455                   : ECamSettingItemShowCapturedPhoto      );
       
  7456   
       
  7457   return ( ECamSettOn == iController.IntegerSettingValue( settingId ) );
       
  7458   }
       
  7459     
       
  7460 
       
  7461 // ---------------------------------------------------------------------------
       
  7462 // CCamAppUi::SuppressUIRiseOnViewfinderStart
       
  7463 // Whether the automatic UI-rise should be suppressed on
       
  7464 // next viewfinder start event
       
  7465 // ---------------------------------------------------------------------------
       
  7466 //
       
  7467 TBool 
       
  7468 CCamAppUi::SuppressUIRiseOnViewfinderStart() const
       
  7469   {
       
  7470   return iSuppressUIRise;
       
  7471   }
       
  7472     
       
  7473 
       
  7474 // ---------------------------------------------------------------------------
       
  7475 // CCamAppUi::SetSuppressUIRiseOnViewfinderStart
       
  7476 // Sets whether the automatic UI-rise should be suppressed on
       
  7477 // next viewfinder start event
       
  7478 // ---------------------------------------------------------------------------
       
  7479 //
       
  7480 void 
       
  7481 CCamAppUi::SetSuppressUIRiseOnViewfinderStart(TBool aSuppress) 
       
  7482   {
       
  7483   iSuppressUIRise = aSuppress;
       
  7484   }
       
  7485 
       
  7486 
       
  7487 // ---------------------------------------------------------------------------
       
  7488 // CCamAppUi::SelectViewFinderGridSettingL
       
  7489 // Select the viewfinder grid setting.
       
  7490 // Currently only sets the grid ON or OFF.
       
  7491 // ---------------------------------------------------------------------------
       
  7492 //    
       
  7493 void 
       
  7494 CCamAppUi::SelectViewFinderGridSettingL()
       
  7495   {
       
  7496   PRINT( _L("Camera => CCamAppUi::SelectViewFinderGridSettingL") );
       
  7497   PRINT1( _L("Camera <> ECamSettingItemViewfinderGrid == (%d)"), 
       
  7498       ECamSettingItemViewfinderGrid );
       
  7499 
       
  7500   TInt current = iController.IntegerSettingValue( ECamSettingItemViewfinderGrid );
       
  7501   TInt invert  = (current == ECamViewfinderGridOn) 
       
  7502                ? ECamViewfinderGridOff 
       
  7503                : ECamViewfinderGridOn;
       
  7504 
       
  7505   // Switch the value.
       
  7506   iController.SetIntegerSettingValueL( ECamSettingItemViewfinderGrid, invert );
       
  7507 
       
  7508   // We'll get a HandleControllerEventL callback 
       
  7509   // from iController when the value has been set.
       
  7510   PRINT( _L("Camera <= CCamAppUi::SelectViewFinderGridSettingL") );
       
  7511   }
       
  7512 
       
  7513 
       
  7514 // ---------------------------------------------------------------------------
       
  7515 // CCamAppUi::ConstructPostCaptureViewIfRequiredL
       
  7516 //
       
  7517 // Construct a postcapture view if not already constructed
       
  7518 //
       
  7519 // The following parameter combinations can be used:
       
  7520 //      * Still postcapture view: aViewState = ECamViewStatePostCapture, 
       
  7521 //                                aMode      = ECamControllerImage
       
  7522 //      * Burst thumbnail view:   aViewState = ECamViewStateBurstThumbnail
       
  7523 //                                aMode      = << ignored >>
       
  7524 //      * Video postcapture view: aViewState = ECamViewStatePostCapture, 
       
  7525 //                                aMode      = ECamControllerVideo
       
  7526 // ---------------------------------------------------------------------------
       
  7527 //   
       
  7528 void 
       
  7529 CCamAppUi::ConstructPostCaptureViewIfRequiredL( TCamViewState aViewState,
       
  7530                                                 TCamCameraMode aCaptureMode )
       
  7531     {
       
  7532     CAknView* view;
       
  7533     
       
  7534     if( ECamViewStateBurstThumbnail == aViewState )
       
  7535         {
       
  7536         // Burst thumbnail view        
       
  7537         if( !iBurstThumbnailViewConstructed )
       
  7538             {    
       
  7539             PRINT( _L("Camera => CCamAppUi::\
       
  7540                 ConstructPostCaptureViewIfRequiredL - BurstThumbnail") );        
       
  7541             view = CCamBurstThumbnailView::NewLC( iController );
       
  7542             AddViewL( view );
       
  7543             CleanupStack::Pop( view );
       
  7544             iBurstThumbnailViewConstructed = ETrue;
       
  7545             PRINT( _L("Camera <= CCamAppUi::\
       
  7546                 ConstructPostCaptureViewIfRequiredL - BurstThumbnail") );    
       
  7547             }                        
       
  7548         }
       
  7549     else if( ECamViewStatePostCapture == aViewState )
       
  7550         {
       
  7551         if( ECamControllerVideo == aCaptureMode )
       
  7552             {
       
  7553             // Video postcapture
       
  7554             if( !iVideoPostCaptureViewConstructed )
       
  7555                 {
       
  7556                 PRINT( _L("Camera => \
       
  7557                     CCamAppUi::ConstructPostCaptureViewIfRequiredL \
       
  7558                     - VideoPostCapture") );    
       
  7559                 view = CCamVideoPostCaptureView::NewLC( iController );
       
  7560                 AddViewL( view );
       
  7561                 CleanupStack::Pop( view );
       
  7562                 iVideoPostCaptureViewConstructed = ETrue;
       
  7563                 PRINT( _L("Camera <= \
       
  7564                     CCamAppUi::ConstructPostCaptureViewIfRequiredL \
       
  7565                     - VideoPostCapture") );    
       
  7566                 }            
       
  7567             }
       
  7568         else
       
  7569             {
       
  7570             // Still postcapture
       
  7571             if( !iStillPostCaptureViewConstructed )
       
  7572                 {                         
       
  7573                 PRINT( _L("Camera => \
       
  7574                     CCamAppUi::ConstructPostCaptureViewIfRequiredL \
       
  7575                     - StillPostCapture") );                             
       
  7576                 view = CCamStillPostCaptureView::NewLC( iController );
       
  7577                 AddViewL( view );
       
  7578                 CleanupStack::Pop( view );    
       
  7579                 iStillPostCaptureViewConstructed = ETrue;
       
  7580                 PRINT( _L("Camera <= \
       
  7581                     CCamAppUi::ConstructPostCaptureViewIfRequiredL \
       
  7582                      - StillPostCapture") );    
       
  7583                 }
       
  7584             }
       
  7585         }
       
  7586     }
       
  7587     
       
  7588 
       
  7589 #ifdef CAMERAAPP_DELAYED_POSTCAPTURE_CREATION
       
  7590 
       
  7591 // ---------------------------------------------------------------------------
       
  7592 // CCamAppUi::StartPostCapIdleL
       
  7593 //
       
  7594 // Starts calls to PostCapIdleCallBack during processor idle time. The calls
       
  7595 // are continued until PostCapIdleCallBack is done.
       
  7596 //    
       
  7597 // ---------------------------------------------------------------------------
       
  7598 void CCamAppUi::StartPostCapIdleL()
       
  7599     {
       
  7600     if( !iPostCapIdle )
       
  7601         {
       
  7602         iPostCapIdle = CIdle::NewL( CActive::EPriorityIdle );
       
  7603         iPostCapProgress = ECamConstructStillPostCap;
       
  7604         iPostCapIdle->Start( TCallBack( PostCapIdleCallBack, this ) );
       
  7605         }
       
  7606     else
       
  7607         {
       
  7608         // iPostCapIdle already exists.
       
  7609         // Do nothing - the views have already been constructed
       
  7610         }        
       
  7611     }
       
  7612     
       
  7613 // ---------------------------------------------------------------------------
       
  7614 // CCamAppUi::PostCapIdleCallBack
       
  7615 //
       
  7616 // Handles postcapture view construction so that each call to this function
       
  7617 // constructs one postcapture view. Returns ETrue if there are still more views
       
  7618 // to construct, EFalse if all are finished and no further calls are required.
       
  7619 //    
       
  7620 // ---------------------------------------------------------------------------    
       
  7621 TInt CCamAppUi::PostCapIdleCallBack( TAny* aSelf )
       
  7622     {
       
  7623     PRINT( _L("Camera => CCamAppUi::PostCapIdleCallBack") );
       
  7624     TInt ret = EFalse;
       
  7625         
       
  7626     CCamAppUi* self = static_cast<CCamAppUi*>( aSelf );
       
  7627     if( self )    
       
  7628         {  
       
  7629         if( ECamConstructStillPostCap == self->iPostCapProgress )
       
  7630             {
       
  7631             TRAP_IGNORE( self->ConstructPostCaptureViewIfRequiredL(
       
  7632                 ECamViewStatePostCapture, ECamControllerImage ) );
       
  7633             self->iPostCapProgress = ECamConstructBurstPostCap;    
       
  7634             ret = ETrue;
       
  7635             }
       
  7636         else if( ECamConstructBurstPostCap == self->iPostCapProgress )
       
  7637             {
       
  7638             TRAP_IGNORE( self->ConstructPostCaptureViewIfRequiredL(
       
  7639                 ECamViewStateBurstThumbnail, ECamControllerImage ) );
       
  7640             self->iPostCapProgress = ECamConstructVideoPostCap;
       
  7641             ret = ETrue;
       
  7642             }
       
  7643         else if( ECamConstructVideoPostCap == self->iPostCapProgress )
       
  7644             {
       
  7645             TRAP_IGNORE( self->ConstructPostCaptureViewIfRequiredL(
       
  7646                 ECamViewStatePostCapture, ECamControllerVideo ) );
       
  7647             self->iPostCapProgress = ECamPostCapsDone;
       
  7648             // Complete
       
  7649             ret = EFalse;
       
  7650             }                                  
       
  7651         }
       
  7652         
       
  7653     PRINT( _L("Camera <= CCamAppUi::PostCapIdleCallBack") );        
       
  7654     return ret;
       
  7655     }
       
  7656 
       
  7657 #endif // CAMERAAPP_DELAYED_POSTCAPTURE_CREATION
       
  7658 
       
  7659 
       
  7660 // ---------------------------------------------------------------------------
       
  7661 // CCamAppUi::StartSensorIdleL
       
  7662 //
       
  7663 // Initiates a call to SensorIdleCallback during processor idle time
       
  7664 // ---------------------------------------------------------------------------
       
  7665 // 
       
  7666 void CCamAppUi::StartSensorIdleL()
       
  7667     {
       
  7668     if ( iController.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
  7669     	{
       
  7670 	    if( iSensorIdleRunning )
       
  7671 	        {
       
  7672 	        // Delayed sensor initialization is already in progress  
       
  7673 	        return;  
       
  7674 	        }  
       
  7675 	      
       
  7676 	    if( !iSensorIdle )
       
  7677 	        {
       
  7678 	        // Instantiate new CIdle  
       
  7679 	        iSensorIdle = CIdle::NewL( CActive::EPriorityIdle );   
       
  7680 	        }
       
  7681 	    else
       
  7682 	        {
       
  7683 	        // Cancel existing the existing request, just in case
       
  7684 	        iSensorIdle->Cancel();  
       
  7685 	        }     
       
  7686 	     
       
  7687 	    // Initialize the idle callback   
       
  7688 	    iSensorIdle->Start( TCallBack( SensorIdleCallBack, this ) );                
       
  7689 	    iSensorIdleRunning = ETrue;
       
  7690 		}
       
  7691     }
       
  7692 
       
  7693 // ---------------------------------------------------------------------------
       
  7694 // CCamAppUi::CancelSensorIdle
       
  7695 //
       
  7696 // Cancels the (possibly) pending call to SensorIdleCallBack
       
  7697 // ---------------------------------------------------------------------------
       
  7698 // 
       
  7699 void CCamAppUi::CancelSensorIdle()
       
  7700     {
       
  7701 		if ( iController.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
  7702 			{
       
  7703 	    if( iSensorIdle && iSensorIdleRunning )
       
  7704 	        {
       
  7705 	        iSensorIdle->Cancel();  
       
  7706 	        iSensorIdleRunning = EFalse;  
       
  7707 	        }
       
  7708       }
       
  7709     }
       
  7710     
       
  7711 // ---------------------------------------------------------------------------
       
  7712 // CCamAppUi::SensorIdleCallBack
       
  7713 //
       
  7714 // Calls iControler.UpdateSensorApiL
       
  7715 // ---------------------------------------------------------------------------
       
  7716 //    
       
  7717 TInt CCamAppUi::SensorIdleCallBack( TAny* aSelf )
       
  7718     {
       
  7719     CCamAppUi* self = static_cast<CCamAppUi*>( aSelf );
       
  7720     
       
  7721     if( self ) 
       
  7722         {
       
  7723         TRAP_IGNORE( self->iController.UpdateSensorApiL( ETrue ) );
       
  7724         self->iSensorIdleRunning = EFalse;
       
  7725         }
       
  7726     return EFalse; // No more calls needed
       
  7727     }
       
  7728 
       
  7729 
       
  7730 // ---------------------------------------------------------------------------
       
  7731 // CCamAppUi::IsSelfTimedCapture
       
  7732 // Whether the current capture was selftimer initiated
       
  7733 // ---------------------------------------------------------------------------
       
  7734 //         
       
  7735 TBool CCamAppUi::IsSelfTimedCapture() const
       
  7736     {
       
  7737     return iSelfTimedCapture;
       
  7738     }
       
  7739 
       
  7740 // ---------------------------------------------------------------------------
       
  7741 // CCamAppUi::DismissMemoryNoteL
       
  7742 // Dismisses out of memory / memory card removed note, if active.
       
  7743 // ---------------------------------------------------------------------------
       
  7744 //
       
  7745 void
       
  7746 CCamAppUi::DismissMemoryNoteL()  
       
  7747   {
       
  7748   if( iMemoryNote )
       
  7749     {         
       
  7750     if( iMemoryNote->IsFocused() )
       
  7751       {
       
  7752       // For some reason, the note's softkeys are displayed in standby mode,
       
  7753       // even though the note itself has been dismissed (=deleted)
       
  7754       // HACK:
       
  7755       // If the note is focused, we know that also its softkeys are in use,
       
  7756       // so we can simulate key events to emulate user closing the note
       
  7757       // using left softkey.
       
  7758       
       
  7759       TKeyEvent key;
       
  7760       key.iRepeats = 0;
       
  7761       key.iCode = EKeyDevice0;
       
  7762       key.iModifiers = 0;
       
  7763       iEikonEnv->SimulateKeyEventL( key, EEventKeyDown );
       
  7764       CEikButtonGroupContainer::Current()->OfferKeyEventL( key, 
       
  7765           EEventKeyDown );            
       
  7766       }
       
  7767 
       
  7768     // Make sure the note closes even if it wasn't focused.
       
  7769     delete iMemoryNote;
       
  7770     iMemoryNote = NULL;                           
       
  7771     }               
       
  7772   }
       
  7773 
       
  7774 
       
  7775 // ---------------------------------------------------------------------------
       
  7776 // Starts Gallery Application command line
       
  7777 // ---------------------------------------------------------------------------
       
  7778 //
       
  7779 
       
  7780 
       
  7781 void
       
  7782 CCamAppUi::StartAppCmdLineL( const TDes8& aData )
       
  7783     {
       
  7784     // MM not running yet - use Command Line Tail
       
  7785     RApaLsSession appArcSession;
       
  7786     CleanupClosePushL( appArcSession );
       
  7787     User::LeaveIfError( appArcSession.Connect() );      
       
  7788     TApaAppInfo appInfo;
       
  7789     User::LeaveIfError( appArcSession.GetAppInfo( appInfo,
       
  7790            TUid::Uid( KGlxGalleryApplicationUid) ) );
       
  7791 
       
  7792     CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
  7793     cmdLine->SetExecutableNameL( appInfo.iFullName );
       
  7794     cmdLine->SetCommandL( EApaCommandRun );   
       
  7795     cmdLine->SetTailEndL( aData );
       
  7796    
       
  7797     User::LeaveIfError( appArcSession.StartApp( *cmdLine ) );      
       
  7798   
       
  7799     CleanupStack::PopAndDestroy( cmdLine );
       
  7800     CleanupStack::PopAndDestroy( &appArcSession ); 
       
  7801     }
       
  7802 // ---------------------------------------------------------------------------
       
  7803 // CCamAppUi::StartCheckingDefaultAlbumIdL()
       
  7804 // We start check operation to see if "Default Album exists"
       
  7805 // Usecase: Whenever the camera returns from background/startup we first start
       
  7806 // checking the default album which is set, if any, to make sure that album 
       
  7807 // really exists. If not, then we set back the value of setting item "Add to 
       
  7808 // album" to "No" in Image/Video setting image settings
       
  7809 // ---------------------------------------------------------------------------
       
  7810 //
       
  7811 void CCamAppUi::StartCheckingDefaultAlbumIdL()
       
  7812     {
       
  7813     TBool checkAlbum = ( 
       
  7814             iController.IntegerSettingValue( 
       
  7815                             ECamSettingItemPhotoStoreInAlbum ) == ECamSettYes ||
       
  7816             iController.IntegerSettingValue( 
       
  7817                             ECamSettingItemVideoStoreInAlbum ) == ECamSettYes );
       
  7818 
       
  7819     if ( !iCheckOperationInProgress && checkAlbum )
       
  7820         {
       
  7821         TUint32 defaultAlbumId = 
       
  7822         static_cast<TUint32> ( 
       
  7823                 iController.IntegerSettingValue( 
       
  7824                         ECamSettingItemDefaultAlbumId ) );
       
  7825         if ( iCollectionManager )
       
  7826             {
       
  7827             iCheckOperationInProgress = ETrue;
       
  7828             iCollectionManager->CheckForAlbumExistenceL( defaultAlbumId );
       
  7829             }
       
  7830         }
       
  7831 
       
  7832     }
       
  7833 
       
  7834 // ---------------------------------------------------------------------------
       
  7835 // CCamAppUi::CheckAlbumIdOperationCompleteL
       
  7836 // Call back method, which is called once the check operation is complete
       
  7837 // ---------------------------------------------------------------------------
       
  7838 //
       
  7839 void CCamAppUi::CheckAlbumIdOperationCompleteL( 
       
  7840     TBool aAlbumExists, const TDesC& /*aAlbumTitle*/ )
       
  7841     {
       
  7842     PRINT( _L("CCamAppUi::CheckAlbumIdOperationCompleteL --> ENTERS") );
       
  7843     if ( iController.UiConfigManagerPtr()->IsPhotosSupported() )
       
  7844         {
       
  7845         if ( iCheckOperationInProgress )
       
  7846             {
       
  7847             PRINT( _L("CheckAlbumIdOperationCompleteL \
       
  7848                 iCheckOperationInProgress: ETRUE") );
       
  7849             iCheckOperationInProgress = EFalse;
       
  7850             if ( !aAlbumExists )
       
  7851                 {
       
  7852                 // Reset all the values to the default ones, 
       
  7853                 // if the default album doesnt exist, when returned from background
       
  7854                 iController.SetIntegerSettingValueL( 
       
  7855                                      ECamSettingItemPhotoStoreInAlbum,
       
  7856                                      ECamSettNo );
       
  7857                 iController.SetIntegerSettingValueL( 
       
  7858                                      ECamSettingItemVideoStoreInAlbum,
       
  7859                                      ECamSettNo );
       
  7860                 // reseting the album id to the default value "0"
       
  7861                 iController.SetIntegerSettingValueL(
       
  7862                                      ECamSettingItemDefaultAlbumId,
       
  7863                                      0 );
       
  7864                 }
       
  7865             }        
       
  7866         }
       
  7867     PRINT( _L("CCamAppUi::CheckAlbumIdOperationCompleteL <-- EXITS") );
       
  7868     }
       
  7869 
       
  7870 
       
  7871 // ---------------------------------------------------------------------------
       
  7872 // CCamAppUi::SettingsLaunchedFromCamera()
       
  7873 // We keep track of plugin event launched from camera
       
  7874 // ---------------------------------------------------------------------------
       
  7875 //
       
  7876 TBool CCamAppUi::SettingsLaunchedFromCamera() const
       
  7877     {
       
  7878     return iSettingsPluginLaunched;
       
  7879     }
       
  7880 
       
  7881 
       
  7882 // ---------------------------------------------------------------------------
       
  7883 // CCamAppUi::SettingsPluginExitedL
       
  7884 // We handle the case when settings plugin exists
       
  7885 // ---------------------------------------------------------------------------
       
  7886 //
       
  7887 void CCamAppUi::SettingsPluginExitedL( TCamSettingsPluginExitMessage aType )
       
  7888     {
       
  7889     iSettingsPluginLaunched =  EFalse;
       
  7890     iTargetViewState = ECamViewStatePreCapture;
       
  7891     TrySwitchViewL();
       
  7892 
       
  7893     switch ( aType )
       
  7894         {
       
  7895         case ECameraPluginExit:
       
  7896             {
       
  7897             // we exit the plugin and switch to pre-capture
       
  7898             iReturnedFromPlugin = ETrue;
       
  7899             break;
       
  7900             }
       
  7901         case ECameraInternalExit:
       
  7902              {
       
  7903              // Internal Exit from Plugin -> Options -> Exit
       
  7904              iReturnedFromPlugin = EFalse;
       
  7905              InternalExitL();
       
  7906              break;
       
  7907              }
       
  7908         case ECameraCompleteExit:
       
  7909              {
       
  7910              // Plugiin -> End Key or "c" key
       
  7911              iReturnedFromPlugin = EFalse;
       
  7912              break;
       
  7913              }
       
  7914         }
       
  7915     PRINT( _L("Camera <= CCamAppUi::SettingsPluginExitedL") );	    
       
  7916     }
       
  7917 
       
  7918 // ---------------------------------------------------------------------------
       
  7919 // CCamAppUi::StaticSettingsModel()
       
  7920 //
       
  7921 // Gets the handle to the settings model, which is used inturn by the
       
  7922 // plugin to call the interfaces for performing needed actions.
       
  7923 // ---------------------------------------------------------------------------
       
  7924 //
       
  7925 MCamStaticSettings& 
       
  7926 CCamAppUi::StaticSettingsModel()
       
  7927     {
       
  7928     return iController.StaticSettingsModel();
       
  7929     }
       
  7930 
       
  7931 // ---------------------------------------------------------------------------
       
  7932 // CCamAppUi::CreateNaviBitmapsL
       
  7933 // Draw the counter to the bitmap used in the navi pane
       
  7934 // ---------------------------------------------------------------------------
       
  7935 //
       
  7936 void 
       
  7937 CCamAppUi::CreateNaviBitmapsL( TBool aDrawStorageIconAndCounter )
       
  7938     {
       
  7939     if ( iNaviCounterModel )
       
  7940         {
       
  7941 	    iNaviCounterModel->CreateNaviBitmapsL( aDrawStorageIconAndCounter );
       
  7942 	    }
       
  7943     }
       
  7944 
       
  7945 // ---------------------------------------------------------------------------
       
  7946 // CCamAppUi::ReadyToDraw
       
  7947 // Checks whether its safe to draw controls
       
  7948 // ---------------------------------------------------------------------------
       
  7949 //
       
  7950 TBool CCamAppUi::ReadyToDraw() const
       
  7951     {
       
  7952     if ( AppInBackground( ETrue ) || !iView )
       
  7953         {
       
  7954         return EFalse;
       
  7955         }
       
  7956     else 
       
  7957         {
       
  7958         return ETrue;
       
  7959         }
       
  7960     }
       
  7961 
       
  7962 // ---------------------------------------------------------------------------
       
  7963 // CCamAppUi::StartFileNameCheck
       
  7964 // Checks whether the file name is deleted/renamed outside camera
       
  7965 // ---------------------------------------------------------------------------
       
  7966 //
       
  7967 void CCamAppUi::StartFileNameCheck()
       
  7968     {
       
  7969     PRINT( _L("Camera => CCamAppUi::StartFileNameCheck") );
       
  7970     if( !iFileCheckAo->IsActive() )
       
  7971         {
       
  7972         iFileCheckAo->Start();
       
  7973         }
       
  7974     PRINT( _L("Camera <= CCamAppUi::StartFileNameCheck") );
       
  7975     }
       
  7976 
       
  7977 
       
  7978 // ---------------------------------------------------------------------------
       
  7979 // CCamAppUi::FileCheckingComplete
       
  7980 // Handle a file checking complete event. Used to inform
       
  7981 // when filechecking active object.
       
  7982 // has finished checking existance of files.
       
  7983 // ---------------------------------------------------------------------------
       
  7984 //
       
  7985 void CCamAppUi::FileCheckingCompleteL( TInt aStatus, TInt aError )
       
  7986   {
       
  7987   PRINT2( _L("Camera => CCamAppUi::FileCheckingComplete(), \
       
  7988       aStatus=%d, aError=%d "), aStatus, aError )
       
  7989 
       
  7990   if( aStatus <= 0 || KErrNone != aError )
       
  7991       {
       
  7992       PRINT( _L("Camera <> CCamAppUi::FileCheckingComplete: \
       
  7993       all files deleted, trying viewswitch") );
       
  7994       iTargetViewState = ECamViewStatePreCapture;      	
       
  7995       TrySwitchViewL( ETrue );		  	
       
  7996       }
       
  7997   else if ( aStatus < iController.BurstCaptureArray()->Count() )
       
  7998       {
       
  7999       PRINT2( _L("Camera <> CCamAppUi::FileCheckingComplete: %d < %d,\
       
  8000               some file(s) have been deleted"),
       
  8001               aStatus,
       
  8002               iController.BurstCaptureArray()->Count() );
       
  8003       
       
  8004       if ( iViewState == ECamViewStateBurstThumbnail || iViewState == ECamViewStatePostCapture )
       
  8005           {
       
  8006           PRINT( _L("Camera <> CCamAppUi::FileCheckingComplete() updating thumbnail view") );
       
  8007           CCamBurstThumbnailView* thumbnailView =
       
  8008           static_cast<CCamBurstThumbnailView*>( View( TUid::Uid( ECamViewIdBurstThumbnail ) ) );
       
  8009 
       
  8010           if ( thumbnailView )
       
  8011               {
       
  8012               thumbnailView->ImageFilesDeleted();
       
  8013               }
       
  8014           
       
  8015           if ( iViewState == ECamViewStatePostCapture )
       
  8016               {
       
  8017               // view state is post-capture, check if the image currently viewed has been deleted
       
  8018               if ( iController.BurstCaptureArray()->IsDeleted( iController.CurrentImageIndex() ) )
       
  8019                   {
       
  8020                   //switch back to burst thumbnail view
       
  8021                   HandleCommandL( EAknSoftkeyBack );
       
  8022                   }
       
  8023               
       
  8024               }
       
  8025           }
       
  8026       }
       
  8027 
       
  8028   //When return to video post capture view from background, we need to determine whether show the toolbar
       
  8029   if( iReturnFromBackground
       
  8030       && iViewState == ECamViewStatePostCapture
       
  8031       && iMode == ECamControllerVideo )
       
  8032       {
       
  8033       SetToolbarVisibility();
       
  8034       }
       
  8035 
       
  8036   PRINT( _L("Camera <= CCamAppUi::FileCheckingComplete()") );
       
  8037   }
       
  8038 	
       
  8039 // ---------------------------------------------------------------------------
       
  8040 // CCamAppUi::HandleSelfTimerEvent
       
  8041 // Handle self-timer event
       
  8042 // ---------------------------------------------------------------------------
       
  8043 //
       
  8044 void CCamAppUi::HandleSelfTimerEvent( TCamSelfTimerEvent aEvent,
       
  8045                                       TInt aCountDown )
       
  8046     {
       
  8047 #if defined( CAMERAAPP_CAPI_V2_DVF )
       
  8048     TRAP_IGNORE( HandleCommandL( ECamCmdRedrawScreen ) );
       
  8049 #else
       
  8050     (void) aEvent;
       
  8051     (void) aCountDown;
       
  8052 #endif // CAMERAAPP_CAPI_V2_DVF
       
  8053     }
       
  8054 
       
  8055 // ---------------------------------------------------------------------------
       
  8056 // CCamAppUi::RequestedNewFileResolution
       
  8057 // Set the requested resolution for a new file
       
  8058 // ---------------------------------------------------------------------------
       
  8059 //
       
  8060 void CCamAppUi::SetRequestedNewFileResolution(
       
  8061     const TSize& aRequestedResolution )
       
  8062     {
       
  8063     iRequestedNewFileResolution.SetSize(
       
  8064         aRequestedResolution.iWidth,
       
  8065         aRequestedResolution.iHeight );
       
  8066     }
       
  8067 
       
  8068 // ---------------------------------------------------------------------------
       
  8069 // CCamAppUi::RequestedNewFileResolution
       
  8070 // Get the requested resolution for a new file
       
  8071 // ---------------------------------------------------------------------------
       
  8072 //
       
  8073 TSize CCamAppUi::RequestedNewFileResolution() const
       
  8074     {
       
  8075     // Default is TSize(0, 0) which interpreted as MMS quality resolution
       
  8076     return iRequestedNewFileResolution;
       
  8077     }
       
  8078 
       
  8079 // ---------------------------------------------------------------------------
       
  8080 // CCamAppUi::SetToolbarVisibility
       
  8081 // Set toolbar visibility in according to whether current view and 
       
  8082 // mode are fit. When embedded camera starts up, view and mode may 
       
  8083 // not be fit.
       
  8084 // ---------------------------------------------------------------------------
       
  8085 //
       
  8086 void CCamAppUi::SetToolbarVisibility()
       
  8087     {
       
  8088     // fixed toolbar is used only with touch devices
       
  8089     CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  8090     if ( iController.IsTouchScreenSupported() && fixedToolbar )  
       
  8091         {
       
  8092         if ( IsEmbedded() )
       
  8093             {
       
  8094             // Check that iMode matches iTargetMode and that the corresponding
       
  8095             // view is active.
       
  8096             if ( iMode == iTargetMode &&
       
  8097                 ( ( iMode == ECamControllerVideo && iView == iVideoCaptureView ) ||
       
  8098                   ( iMode == ECamControllerImage && iView == iStillCaptureView ) ) )
       
  8099                 {
       
  8100                 fixedToolbar->SetToolbarVisibility( ETrue );
       
  8101                 }
       
  8102             else
       
  8103                 {
       
  8104                 fixedToolbar->SetToolbarVisibility( EFalse );
       
  8105                 }
       
  8106             }
       
  8107         else
       
  8108             {
       
  8109             if( (iPreCaptureMode != ECamPreCapCaptureSetup) && 
       
  8110                 (iPreCaptureMode != ECamPreCapGenericSetting) && 
       
  8111                 (iPreCaptureMode != ECamPreCapSceneSetting ) )
       
  8112                 {
       
  8113                 fixedToolbar->SetToolbarVisibility( ETrue );
       
  8114                 }
       
  8115             else
       
  8116                 {
       
  8117                 // No toolbar with the settings view
       
  8118                 fixedToolbar->SetToolbarVisibility( EFalse );
       
  8119                 }
       
  8120             }
       
  8121         }
       
  8122     }
       
  8123 
       
  8124 // ---------------------------------------------------------------------------
       
  8125 // CCamAppUi::SubmergeToolbar
       
  8126 // Hide toolbar if needed.
       
  8127 // ---------------------------------------------------------------------------
       
  8128 //
       
  8129 void CCamAppUi::SubmergeToolbar()
       
  8130     {
       
  8131     PRINT( _L("Camera => CCamAppUi::SubmergeToolbar()") );
       
  8132     // fixed toolbar is used only with touch devices
       
  8133     CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  8134     if ( iController.IsTouchScreenSupported() && fixedToolbar )  
       
  8135         {
       
  8136         fixedToolbar->SetToolbarVisibility( EFalse );
       
  8137         }
       
  8138     PRINT( _L("Camera <= CCamAppUi::SubmergeToolbar()") ); 
       
  8139     }
       
  8140 
       
  8141 // ---------------------------------------------------------------------------
       
  8142 // Check if it's applicable to use the courtesy UI
       
  8143 // ---------------------------------------------------------------------------
       
  8144 //
       
  8145 TBool CCamAppUi::CourtesyUiApplies() const
       
  8146     {
       
  8147     return ( ECamCapturing != iController.CurrentVideoOperation()
       
  8148              && ECamPaused != iController.CurrentVideoOperation()
       
  8149              && !SelfTimerEnabled()
       
  8150              && ( ECamOrientationCamcorder == iCamOrientation ||
       
  8151                   ECamOrientationCamcorderLeft == iCamOrientation ||
       
  8152                   ECamOrientationPortrait == iCamOrientation ) );
       
  8153     }
       
  8154 
       
  8155 // -----------------------------------------------------------------------------
       
  8156 // CCamAppUi::IsToolBarVisible
       
  8157 // Returns whether or the tool bar has been activated
       
  8158 // Will return ETrue when when the tool bar is active
       
  8159 // -----------------------------------------------------------------------------
       
  8160 //
       
  8161 TBool CCamAppUi::IsToolBarVisible() const
       
  8162     {
       
  8163     PRINT1( _L("Camera => CCamAppUi::IsToolBarVisible %d" ), iToolbarVisibility )
       
  8164     return iToolbarVisibility;
       
  8165     }
       
  8166 
       
  8167 
       
  8168 // -----------------------------------------------------------------------------
       
  8169 // CCamAppUi::SetAssumePostCaptureView
       
  8170 // Sets iAssumePostCapture flag according to aValue
       
  8171 // -----------------------------------------------------------------------------
       
  8172 //
       
  8173 void CCamAppUi::SetAssumePostCaptureView( TBool aValue )
       
  8174     {
       
  8175     if ( iView 
       
  8176          && ( iStillCaptureView == iView || iVideoCaptureView == iView ) )
       
  8177         {	
       
  8178         static_cast<CCamPreCaptureViewBase*>( iView )->SetPostCaptureViewAsumption( aValue );	
       
  8179         }
       
  8180     }
       
  8181     
       
  8182 // --------------------------------------------------------------------------- 
       
  8183 // CCamAppUi::SetDrawPreCaptureCourtesyUI 
       
  8184 // Set iDrawPreCaptureCourtesyUI flag 
       
  8185 // --------------------------------------------------------------------------- 
       
  8186 // 
       
  8187 void CCamAppUi::SetDrawPreCaptureCourtesyUI(TBool iDraw) 
       
  8188     { 
       
  8189         if( iDraw ) 
       
  8190             { 
       
  8191             iDrawPreCaptureCourtesyUI = ETrue; 
       
  8192             } 
       
  8193         else 
       
  8194             { 
       
  8195             iDrawPreCaptureCourtesyUI = EFalse; 
       
  8196             } 
       
  8197     } 
       
  8198 
       
  8199 // -----------------------------------------------------------------------------
       
  8200 // CCamAppUi::IsMemoryFullOrUnavailable
       
  8201 // -----------------------------------------------------------------------------
       
  8202 //
       
  8203 TBool 
       
  8204 CCamAppUi::IsMemoryFullOrUnavailable(const TCamMediaStorage 
       
  8205 									 aStorageLocation) const
       
  8206 	{
       
  8207 	if(!iController.IsMemoryAvailable(aStorageLocation))
       
  8208 		return ETrue;
       
  8209 	
       
  8210 	if(iMode == ECamControllerImage)
       
  8211 		{
       
  8212 		TInt availableMemoryUnits = 0;
       
  8213 		availableMemoryUnits = 
       
  8214 			iController.ImagesRemaining(aStorageLocation,EFalse);
       
  8215 		return (availableMemoryUnits <= 0);
       
  8216 		}
       
  8217 	else if(iMode == ECamControllerVideo)
       
  8218 		{
       
  8219 		TTimeIntervalMicroSeconds timeLeft = 0;
       
  8220 		TRAPD(err,timeLeft =
       
  8221 					iController.
       
  8222 					CalculateVideoTimeRemainingL(aStorageLocation););
       
  8223 		if(err)
       
  8224 		    timeLeft = 0;
       
  8225 		return (timeLeft < KMemoryFullVideoRemaining);
       
  8226 		}
       
  8227 	return ETrue;
       
  8228 	}
       
  8229 
       
  8230 // -----------------------------------------------------------------------------
       
  8231 // CCamAppUi::AllMemoriesFullOrUnavailable
       
  8232 // -----------------------------------------------------------------------------
       
  8233 //
       
  8234 TBool CCamAppUi::AllMemoriesFullOrUnavailable() const
       
  8235 	{
       
  8236 	return ( IsMemoryFullOrUnavailable(ECamMediaStoragePhone) &&
       
  8237 		   IsMemoryFullOrUnavailable(ECamMediaStorageCard) &&
       
  8238 		   IsMemoryFullOrUnavailable(ECamMediaStorageMassStorage) );
       
  8239 	}
       
  8240 
       
  8241     
       
  8242 // ---------------------------------------------------------
       
  8243 // CCamAppUi::AppUIConstructCallbackL
       
  8244 // 
       
  8245 // ---------------------------------------------------------
       
  8246 //
       
  8247 TInt CCamAppUi::AppUIConstructCallbackL( TAny* aAny )
       
  8248     {
       
  8249     PRINT( _L("Camera => CCamAppUi::AppUIConstructCallbackL") )
       
  8250     CCamAppUi* appui = static_cast<CCamAppUi*>( aAny );
       
  8251     __ASSERT_DEBUG( appui != NULL && appui->iWaitTimer != NULL, CamPanic( ECamPanicNullPointer ) );
       
  8252     appui->iWaitTimer->Cancel();
       
  8253     if ( !appui->IsUiConstructionComplete() )
       
  8254         {
       
  8255         appui->CompleteAppUIConstructionL();
       
  8256         }
       
  8257     PRINT( _L("Camera <= CCamAppUi::AppUIConstructCallbackL") )
       
  8258     return KErrNone;
       
  8259     }    
       
  8260 
       
  8261 // ---------------------------------------------------------
       
  8262 // CCamAppUi::CompleteAppUIConstructionL
       
  8263 // 
       
  8264 // ---------------------------------------------------------
       
  8265 //    
       
  8266 void CCamAppUi::CompleteAppUIConstructionL()
       
  8267     {
       
  8268     PRINT( _L("Camera => CCamAppUi::CompleteAppUIConstructionL") )
       
  8269     iUiConstructionComplete = ETrue; 
       
  8270     // Load the settings model static settings
       
  8271     PRINT( _L("Camera <> call CCamAppController::LoadStaticSettingsL..") )
       
  8272     iController.LoadStaticSettingsL( IsEmbedded() );
       
  8273     // store the userscene settings
       
  8274     iController.StoreUserSceneSettingsL();
       
  8275 
       
  8276 /*#ifndef __WINSCW__    
       
  8277         if ( !iSFIUtils )
       
  8278             {
       
  8279             // Initialize SFIUtils
       
  8280             iSFIUtils = CSFIUtilsAppInterface::NewL();
       
  8281             iSendFileInCall = EFalse;
       
  8282             PRINT( _L("iSendFileInCall = EFalse") );	
       
  8283             }	
       
  8284 #endif        */
       
  8285   
       
  8286     // Create text resolver for error note text
       
  8287     iTextResolver = CTextResolver::NewL();
       
  8288   
       
  8289     ConstructPreCaptureViewsL();
       
  8290   
       
  8291     iSelfTimer = CCamSelfTimer::NewL( iController );
       
  8292 #if defined( CAMERAAPP_CAPI_V2_DVF )
       
  8293     iSelfTimer->AddObserverL( this ); 
       
  8294 #endif // CAMERAAPP_CAPI_V2_DVF
       
  8295 
       
  8296     PRINT( _L("Camera <> creating navicounter model") );
       
  8297     iNaviCounterModel = CCamNaviCounterModel::NewL( iController );
       
  8298     PRINT( _L("Camera <> append navicounter to resourceloaders") );
       
  8299     User::LeaveIfError( iResourceLoaders.Append(iNaviCounterModel) );
       
  8300   
       
  8301     PRINT( _L("Camera <> creating progress bar model") );
       
  8302     iNaviProgressBarModel = CCamNaviProgressBarModel::NewL( iController );
       
  8303     PRINT( _L("Camera <> append progressbar to resourceloaders") );
       
  8304     User::LeaveIfError(iResourceLoaders.Append(iNaviProgressBarModel));
       
  8305   
       
  8306     ConstructNaviPaneL();
       
  8307     
       
  8308     //always start in stillmode
       
  8309     SetDefaultViewL( *iStillCaptureView );
       
  8310         
       
  8311     // pre-construct side-pane & zoom pane
       
  8312     // get whether we overlay sidepane over view-finder
       
  8313     TBool overlayViewFinder;
       
  8314     User::LeaveIfError( CamUtility::GetPsiInt( ECamPsiOverLaySidePane, overlayViewFinder ) );
       
  8315     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create sidepane") );
       
  8316     iCamSidePane = CCamSidePane::NewL( iController, overlayViewFinder );
       
  8317     User::LeaveIfError(iResourceLoaders.Append(iCamSidePane));
       
  8318     
       
  8319     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create zoom pane") );
       
  8320     iCamZoomPane = CCamZoomPane::NewL( iController, overlayViewFinder );
       
  8321     User::LeaveIfError(iResourceLoaders.Append(iCamZoomPane));
       
  8322   
       
  8323     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create doc handler") );
       
  8324     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
       
  8325 
       
  8326     // Check to see if we are set to use mmc storage but the card has
       
  8327     // been removed.  
       
  8328     iController.CheckMemoryToUseL();
       
  8329 
       
  8330     // create navi-pane and navi-porgress bar for use in camcorder mode 
       
  8331     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create navicounter control") );
       
  8332     iNaviCounterControl = CCamNaviCounterControl::NewL( *iNaviCounterModel );
       
  8333     iNaviCounterControl->SetExtentToWholeScreen();
       
  8334   
       
  8335     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create progress bar control") );
       
  8336     iNaviProgressBarControl = CCamNaviProgressBarControl::NewL( *iNaviProgressBarModel );        
       
  8337   
       
  8338     // get max num of images for burst capture
       
  8339     CamUtility::GetPsiInt( ECamPsiMaxBurstCapture, iMaxBurstCaptureNum );
       
  8340   
       
  8341     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create AP handler") );
       
  8342     iActivePaletteHandler = CCamActivePaletteHandler::NewL( iController, EFalse );
       
  8343   
       
  8344     // get coutesy UI timeout
       
  8345     TInt timeoutValue;
       
  8346     CamUtility::GetPsiInt( ECamPsiCourtesyUiTimeoutValue, timeoutValue );
       
  8347   
       
  8348     iCourtesyTimer = CCamTimer::NewL( timeoutValue * 1000000, 
       
  8349                                     TCallBack( CCamAppUi::CourtesyTimeout, this ) );
       
  8350                                     
       
  8351     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL update navi models") );
       
  8352     UpdateNaviModelsL();
       
  8353     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL navi counter reload resources") );
       
  8354     iNaviCounterModel->ReloadResourceDataL();
       
  8355     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL navi progress bar reload resources") );
       
  8356     iNaviProgressBarModel->ReloadResourceDataL();
       
  8357   
       
  8358     iFileCheckAo = CCamFileCheckAo::NewL( iController, *this );  
       
  8359     iCollectionManager = new (ELeave) CCamCollectionManagerAO( *this );
       
  8360     
       
  8361     //iStillCaptureView->Container()->MakeVisible( ETrue );
       
  8362     ActivateLocalViewL( iStillCaptureView->Id() );
       
  8363     
       
  8364     StartCheckingDefaultAlbumIdL();
       
  8365     PRINT( _L("Camera <= CCamAppUi::CompleteAppUIConstructionL") )
       
  8366     }
       
  8367 
       
  8368 // ---------------------------------------------------------
       
  8369 // CCamAppUi::IsUiConstructionComplete()
       
  8370 // 
       
  8371 // ---------------------------------------------------------
       
  8372 //
       
  8373 TBool CCamAppUi::IsUiConstructionComplete()
       
  8374     {
       
  8375     return iUiConstructionComplete;    
       
  8376     }
       
  8377 	
       
  8378 // -----------------------------------------------------------------------------
       
  8379 // CCamAppUi::SetLensCoverExit 
       
  8380 // Sets iLensCoverExit flag according to aValue
       
  8381 // -----------------------------------------------------------------------------
       
  8382 //
       
  8383 void CCamAppUi::SetLensCoverExit( TBool aValue )
       
  8384     {
       
  8385     iLensCoverExit = aValue;
       
  8386     }
       
  8387 	
       
  8388 // -----------------------------------------------------------------------------
       
  8389 // CCamAppUi::SetViewFinderStoppedStatus 
       
  8390 // set whether camera viewfinder stop or not
       
  8391 // @param aViewFinderStopped ETrue viewfinder is stoped,EFalse viewfinder is runing
       
  8392 // -----------------------------------------------------------------------------
       
  8393 //
       
  8394 void CCamAppUi::SetViewFinderStoppedStatus( TBool aViewFinderStopped )
       
  8395     {
       
  8396     iViewFinderStopped = aViewFinderStopped;
       
  8397     }
       
  8398 
       
  8399 // -----------------------------------------------------------------------------
       
  8400 // CCamAppUi::IsViewFinderInTransit 
       
  8401 // -----------------------------------------------------------------------------
       
  8402 //
       
  8403 TBool CCamAppUi::IsViewFinderInTransit()
       
  8404     {
       
  8405     return iViewFinderInTransit;
       
  8406     }
       
  8407         
       
  8408 // -----------------------------------------------------------------------------
       
  8409 // CCamAppUi::SetViewFinderInTransit 
       
  8410 // -----------------------------------------------------------------------------
       
  8411 //
       
  8412 void CCamAppUi::SetViewFinderInTransit(TBool aInTransit)
       
  8413     {
       
  8414     iViewFinderInTransit = aInTransit;
       
  8415     }
       
  8416 //  End of File