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