camerauis/cameraapp/generic/src/CamAppui.cpp
branchRCL_3
changeset 15 bf64cebf4673
parent 13 38fb6f7eacd5
child 16 53c8aa5d97a3
equal deleted inserted replaced
13:38fb6f7eacd5 15:bf64cebf4673
    93 #include "CamAppUid.h"
    93 #include "CamAppUid.h"
    94 #include <csxhelp/lcam.hlp.hrh>
    94 #include <csxhelp/lcam.hlp.hrh>
    95 #include "CameraVariant.hrh"
    95 #include "CameraVariant.hrh"
    96 #include "OstTraceDefinitions.h"
    96 #include "OstTraceDefinitions.h"
    97 #ifdef OST_TRACE_COMPILER_IN_USE
    97 #ifdef OST_TRACE_COMPILER_IN_USE
    98 #include "CamAppUiTraces.h"
    98 #include "CamAppuiTraces.h"
    99 #endif
    99 #endif
   100 #include "camactivepalettehandler.h"
   100 #include "camactivepalettehandler.h"
   101 #include "CamContainerBase.h"
   101 #include "CamContainerBase.h"
   102 #include "camuidconstants.h"
   102 #include "camuidconstants.h"
   103 #include "CamGSInterface.h"
   103 #include "CamGSInterface.h"
   591   
   591   
   592   if( !uiOrientationOverride )
   592   if( !uiOrientationOverride )
   593     {  
   593     {  
   594     PRINT( _L("Camera => CCamAppUi::ConstructL create doc handler") );
   594     PRINT( _L("Camera => CCamAppUi::ConstructL create doc handler") );
   595     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
   595     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
       
   596     iDocHandler->SetExitObserver(this);
   596   iController.CheckMemoryToUseL();
   597   iController.CheckMemoryToUseL();
   597   
   598   
   598     // create navi-pane and navi-porgress bar for use in camcorder mode 
   599     // create navi-pane and navi-porgress bar for use in camcorder mode 
   599     PRINT( _L("Camera => CCamAppUi::ConstructL create navicounter control") );
   600     PRINT( _L("Camera => CCamAppUi::ConstructL create navicounter control") );
   600     iNaviCounterControl = CCamNaviCounterControl::NewL( *iNaviCounterModel );
   601     iNaviCounterControl = CCamNaviCounterControl::NewL( *iNaviCounterModel );
  1232       }
  1233       }
  1233       break;
  1234       break;
  1234     case EEikCmdExit: // fallthrough
  1235     case EEikCmdExit: // fallthrough
  1235     case EAknSoftkeyExit:
  1236     case EAknSoftkeyExit:
  1236       {
  1237       {
       
  1238       CAknToolbar* fixedToolbar = CurrentFixedToolbar();
       
  1239       if ( fixedToolbar )
       
  1240         {
       
  1241         CAknToolbarExtension* extension = fixedToolbar->ToolbarExtension();
       
  1242         if ( extension )
       
  1243             {
       
  1244             extension->SetShown( EFalse );
       
  1245             }
       
  1246         fixedToolbar->SetToolbarVisibility( EFalse );
       
  1247         } 
  1237       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP3_CCAMAPPUI_HANDLECOMMANDL, "e_ExternalExit 1" );
  1248       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP3_CCAMAPPUI_HANDLECOMMANDL, "e_ExternalExit 1" );
  1238       PRINT( _L("Camera CCamAppUi external exit call") );
  1249       PRINT( _L("Camera CCamAppUi external exit call") );
  1239       if ( iEikonEnv->StartedAsServerApp() )
  1250       if ( iEikonEnv->StartedAsServerApp() )
  1240         {
  1251         {
  1241         if ( iEmbeddedObserver )
  1252         if ( iEmbeddedObserver )
  1682       }
  1693       }
  1683       break;
  1694       break;
  1684     // -----------------------------------------------------
  1695     // -----------------------------------------------------
  1685     case ECamCmdPlay:   
  1696     case ECamCmdPlay:   
  1686       {
  1697       {
  1687       TDataType dataType;
  1698       PRINT1(_L("Camera <=> CCamAppUi::HandleCommandL. case ECamCmdPlay, iVideoClipPlayInProgress:%d"), iVideoClipPlayInProgress);
  1688       SetEmbedding( ETrue );
  1699       
  1689       iDocHandler->OpenFileEmbeddedL( iController.CurrentFullFileName(),
  1700       if ( !iVideoClipPlayInProgress)
  1690                                       dataType );
  1701         {
       
  1702         TDataType dataType;
       
  1703         TInt           err;
       
  1704          
       
  1705         SetEmbedding( ETrue );
       
  1706         
       
  1707         err = iDocHandler->OpenFileEmbeddedL( iController.CurrentFullFileName(),  dataType );
       
  1708         PRINT1(_L("Camera <=> CCamAppUi::HandleCommandL. iDocHandler ->OpenFileEmbeddedL err:%d"), err);
       
  1709         
       
  1710         if ( KErrNone == err)
       
  1711             {
       
  1712             iVideoClipPlayInProgress = ETrue;
       
  1713             }
       
  1714         }  
       
  1715       
  1691       }
  1716       }
  1692       break;
  1717       break;
  1693      // -----------------------------------------------------
  1718      // -----------------------------------------------------
  1694      case ECamCmdSwitchCamera:
  1719      case ECamCmdSwitchCamera:
  1695          {
  1720          {
  1971       // in that case UI construction is divided into two parts, call here 
  1996       // in that case UI construction is divided into two parts, call here 
  1972       // to complete the construction	if in first startup
  1997       // to complete the construction	if in first startup
  1973       if( iFirstBoot )
  1998       if( iFirstBoot )
  1974           {	
  1999           {	
  1975           PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventReserveRequested/ECamCameraEventPowerOnRequested" ) )	
  2000           PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventReserveRequested/ECamCameraEventPowerOnRequested" ) )	
  1976           if ( iWaitTimer->IsActive() )
  2001           // in embedded mode appui construct timer started already
       
  2002           if ( !IsEmbedded() )
  1977               {
  2003               {
  1978               PRINT( _L( "Camera <> timer already active" ) )
  2004               if ( iWaitTimer->IsActive() )
  1979               iWaitTimer->Cancel();
  2005                   {
       
  2006                   PRINT( _L( "Camera <> timer already active" ) )
       
  2007                   iWaitTimer->Cancel();
       
  2008                   }
       
  2009               PRINT( _L( "Camera <> start the appui construct timer" ) )
       
  2010               iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );  
  1980               }
  2011               }
  1981           PRINT( _L( "Camera <> start the appui construct timer" ) )
       
  1982           iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );  
       
  1983           }
  2012           }
  1984       else
  2013       else
  1985           {
  2014           {
  1986           //load settings in case they were changed via GS	
  2015           //load settings in case they were changed via GS	
  1987           iController.LoadStaticSettingsL( IsEmbedded() );
  2016           iController.LoadStaticSettingsL( IsEmbedded() );
  3205               {  
  3234               {  
  3206               StartCheckingDefaultAlbumIdL();
  3235               StartCheckingDefaultAlbumIdL();
  3207               }
  3236               }
  3208   
  3237   
  3209           // Free the needed ram memory if not enough available
  3238           // Free the needed ram memory if not enough available
  3210           iMemoryMonitor->CheckAndRequestMemoryL(
  3239           TInt memError = iMemoryMonitor->CheckAndRequestMemoryL(
  3211                            iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained(),
  3240                            iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained(),
  3212                            iController.UiConfigManagerPtr()->RequiredRamMemoryFocusGained(),
  3241                            iController.UiConfigManagerPtr()->RequiredRamMemoryFocusGained(),
  3213                            EFalse );
  3242                            EFalse );
       
  3243 
       
  3244           TInt freeMemory = 0;
       
  3245           TInt halerror=HAL::Get( HALData::EMemoryRAMFree, freeMemory );
       
  3246           if( halerror != KErrNone )
       
  3247               {
       
  3248               User::Leave( halerror );          
       
  3249               }
       
  3250           
       
  3251           if ( memError && freeMemory < iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained() )
       
  3252               {
       
  3253               PRINT( _L("Camera <> CCamAppUi::HandleWsEvent ECamEventFocusGained memory too low. Exiting") );
       
  3254               CloseAppL();
       
  3255               PRINT( _L("Camera <= CCamAppUi::HandleWsEvent ECamEventFocusGained memory too low. Exiting") );
       
  3256               return;
       
  3257               }
  3214 
  3258 
  3215 
  3259 
  3216           iController.SetEndKeyExitWaiting( EFalse );
  3260           iController.SetEndKeyExitWaiting( EFalse );
  3217           //Don't update task state in case of embedded camera
  3261           //Don't update task state in case of embedded camera
  3218           if ( !iEikonEnv->StartedAsServerApp())
  3262           if ( !iEikonEnv->StartedAsServerApp())
  3327                     !uiOverride )
  3371                     !uiOverride )
  3328               {
  3372               {
  3329               RaisePreCaptureCourtesyUI( ETrue );
  3373               RaisePreCaptureCourtesyUI( ETrue );
  3330               }
  3374               }
  3331           
  3375           
       
  3376           //We hiden toolbar when keylock was set to on in pre-capture view and camera lost focus, 
       
  3377           //so we need to display toolbar when keylock is set to off and camera gain focus again.
       
  3378           if ( ECamViewStatePreCapture == iViewState &&
       
  3379                ECamPreCapViewfinder == iPreCaptureMode )  
       
  3380             {
       
  3381             SetToolbarVisibility(); 
       
  3382             }          
       
  3383           
  3332           // If keylock is set on when recording is starting up but not yet 
  3384           // If keylock is set on when recording is starting up but not yet 
  3333           // started, display toolbar when keylock is set off since we are 
  3385           // started, display toolbar when keylock is set off since we are 
  3334           // returning to precapture view, unless capturing is still going on.
  3386           // returning to precapture view, unless capturing is still going on.
  3335           if ( iView == iVideoCaptureView 
  3387           if ( iView == iVideoCaptureView 
  3336               && iController.CurrentOperation() != ECamCapturing 
  3388               && iController.CurrentOperation() != ECamCapturing 
  3369               && iViewState == ECamViewStatePostCapture
  3421               && iViewState == ECamViewStatePostCapture
  3370               && iMode == ECamControllerVideo )
  3422               && iMode == ECamControllerVideo )
  3371               {
  3423               {
  3372               SubmergeToolbar();
  3424               SubmergeToolbar();
  3373               }
  3425               }
       
  3426               
       
  3427           //We need hiding the toolbar if keylock is set to on in pre-catpure view, 
       
  3428           //otherwise the toolbar will be displayed when press volume key in keylock on status.
       
  3429           if ( iController.IsKeyLockOn() &&
       
  3430                ECamViewStatePreCapture == iViewState && 
       
  3431                ECamPreCapViewfinder == iPreCaptureMode ) 
       
  3432             {
       
  3433             SubmergeToolbar(); 
       
  3434             }
  3374 
  3435 
  3375           // focus lost event while videocall active and camera in standby,
  3436           // focus lost event while videocall active and camera in standby,
  3376           // no notification to views
  3437           // no notification to views
  3377           if ( iController.InVideocallOrRinging()
  3438           if ( iController.InVideocallOrRinging()
  3378             && ECamViewStateStandby == iViewState )
  3439             && ECamViewStateStandby == iViewState )
  6132 //
  6193 //
  6133 void 
  6194 void 
  6134 CCamAppUi::StartAsServerAppL( MCamEmbeddedObserver* aEmbeddedObserver, 
  6195 CCamAppUi::StartAsServerAppL( MCamEmbeddedObserver* aEmbeddedObserver, 
  6135                               TInt                  aMode )
  6196                               TInt                  aMode )
  6136     {       
  6197     {       
  6137     PRINT( _L("Camera => CCamAppUi::StartAsServerAppL") );  
  6198     PRINT1( _L("Camera => CCamAppUi::StartAsServerAppL mode:%d"), aMode );  
  6138 
  6199 
  6139     __ASSERT_ALWAYS( aMode == ECamControllerVideo || aMode == ECamControllerImage, 
  6200     __ASSERT_ALWAYS( aMode == ECamControllerVideo || aMode == ECamControllerImage, 
  6140             CamPanic( ECamPanicNotSupported ) );
  6201             CamPanic( ECamPanicNotSupported ) );
       
  6202 
       
  6203     // start the ui construct timer to speed up the starting in embedded mode
       
  6204     if ( iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
       
  6205         {
       
  6206         if ( iWaitTimer->IsActive() )
       
  6207             {
       
  6208             PRINT( _L( "Camera <> timer already active" ) )
       
  6209             iWaitTimer->Cancel();
       
  6210             }
       
  6211         PRINT( _L( "Camera <> start the appui construct timer" ) )
       
  6212         iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );
       
  6213         }
  6141 
  6214 
  6142     // Load Embedded Settings
  6215     // Load Embedded Settings
  6143     iController.LoadStaticSettingsL( ETrue );
  6216     iController.LoadStaticSettingsL( ETrue );
  6144     iEmbeddedViewSet = ETrue;     
  6217     iEmbeddedViewSet = ETrue;     
  6145     iEmbeddedObserver = aEmbeddedObserver; 
  6218     iEmbeddedObserver = aEmbeddedObserver; 
  6147 
  6220 
  6148 
  6221 
  6149     if ( aMode == ECamControllerVideo )
  6222     if ( aMode == ECamControllerVideo )
  6150         {
  6223         {
  6151         iTargetMode = ECamControllerVideo;
  6224         iTargetMode = ECamControllerVideo;
       
  6225         iMode = ECamControllerVideo;
  6152         }
  6226         }
  6153     else if ( aMode == ECamControllerImage )
  6227     else if ( aMode == ECamControllerImage )
  6154         {
  6228         {
  6155         iTargetMode = ECamControllerImage;
  6229         iTargetMode = ECamControllerImage;
       
  6230         iMode = ECamControllerImage;
  6156         }
  6231         }
  6157 
  6232 
  6158     // Find the parent app's name:
  6233     // Find the parent app's name:
  6159 
  6234 
  6160     RWsSession ws = iEikonEnv->WsSession();
  6235     RWsSession ws = iEikonEnv->WsSession();
  6242         iView->HandleCommandL( ECamCmdExitStandby );
  6317         iView->HandleCommandL( ECamCmdExitStandby );
  6243         }
  6318         }
  6244     iViewState = ECamViewStatePreCapture;    
  6319     iViewState = ECamViewStatePreCapture;    
  6245   iTargetViewState = ECamViewStatePreCapture;   	
  6320   iTargetViewState = ECamViewStatePreCapture;   	
  6246     TrySwitchViewL();                                      
  6321     TrySwitchViewL();                                      
  6247 
  6322     
       
  6323     // Start reserve-poweron sequence
       
  6324     iController.EmbeddedStartupSequence();
  6248 
  6325 
  6249     PRINT( _L("Camera <= CCamAppUi::StartAsServerAppL") );
  6326     PRINT( _L("Camera <= CCamAppUi::StartAsServerAppL") );
  6250     }
  6327     }
  6251            
  6328            
  6252 
  6329 
  7521             precapView->ViewCba()->MakeVisible( ETrue );
  7598             precapView->ViewCba()->MakeVisible( ETrue );
  7522             // fixed toolbar is used only with touch devices
  7599             // fixed toolbar is used only with touch devices
  7523             if ( iController.IsTouchScreenSupported() )
  7600             if ( iController.IsTouchScreenSupported() )
  7524                 {
  7601                 {
  7525                 precapView->CreateAndSetToolbarL( R_CAM_EMPTY_FIXED_TOOLBAR );
  7602                 precapView->CreateAndSetToolbarL( R_CAM_EMPTY_FIXED_TOOLBAR );
       
  7603                 SetToolbarVisibility();
  7526                 }
  7604                 }
  7527             EikSoftkeyPostingTransparency::MakeTransparent(
  7605             EikSoftkeyPostingTransparency::MakeTransparent(
  7528                 *precapView->ViewCba(), EFalse );
  7606                 *precapView->ViewCba(), EFalse );
  7529             }
  7607             }
  7530         SetActivePaletteVisibility( EFalse );
  7608         SetActivePaletteVisibility( EFalse );
  8439     PRINT( _L("Camera <> append progressbar to resourceloaders") );
  8517     PRINT( _L("Camera <> append progressbar to resourceloaders") );
  8440     User::LeaveIfError(iResourceLoaders.Append(iNaviProgressBarModel));
  8518     User::LeaveIfError(iResourceLoaders.Append(iNaviProgressBarModel));
  8441   
  8519   
  8442     ConstructNaviPaneL();
  8520     ConstructNaviPaneL();
  8443     
  8521     
  8444     //always start in stillmode
  8522 
  8445     SetDefaultViewL( *iStillCaptureView );
  8523     //embedded camera may start straight in videomode
  8446         
  8524     if( IsEmbedded() && iTargetMode == ECamControllerVideo )
       
  8525         {
       
  8526         SetDefaultViewL( *iVideoCaptureView );
       
  8527         PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL SetDefaultView Video") );
       
  8528         }
       
  8529     else
       
  8530         {
       
  8531         SetDefaultViewL( *iStillCaptureView );
       
  8532         PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL SetDefaultView Still") );
       
  8533         }
       
  8534                 
  8447     // pre-construct side-pane & zoom pane
  8535     // pre-construct side-pane & zoom pane
  8448     // get whether we overlay sidepane over view-finder
  8536     // get whether we overlay sidepane over view-finder
  8449     TBool overlayViewFinder;
  8537     TBool overlayViewFinder;
  8450     User::LeaveIfError( CamUtility::GetPsiInt( ECamPsiOverLaySidePane, overlayViewFinder ) );
  8538     User::LeaveIfError( CamUtility::GetPsiInt( ECamPsiOverLaySidePane, overlayViewFinder ) );
  8451     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create sidepane") );
  8539     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create sidepane") );
  8456     iCamZoomPane = CCamZoomPane::NewL( iController, overlayViewFinder );
  8544     iCamZoomPane = CCamZoomPane::NewL( iController, overlayViewFinder );
  8457     User::LeaveIfError(iResourceLoaders.Append(iCamZoomPane));
  8545     User::LeaveIfError(iResourceLoaders.Append(iCamZoomPane));
  8458   
  8546   
  8459     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create doc handler") );
  8547     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create doc handler") );
  8460     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
  8548     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
       
  8549     iDocHandler->SetExitObserver(this);    
  8461 
  8550 
  8462     // Check to see if we are set to use mmc storage but the card has
  8551     // Check to see if we are set to use mmc storage but the card has
  8463     // been removed.  
  8552     // been removed.  
  8464     iController.CheckMemoryToUseL();
  8553     iController.CheckMemoryToUseL();
  8465 
  8554 
  8493   
  8582   
  8494     iFileCheckAo = CCamFileCheckAo::NewL( iController, *this );  
  8583     iFileCheckAo = CCamFileCheckAo::NewL( iController, *this );  
  8495     iCollectionManager = new (ELeave) CCamCollectionManagerAO( *this );
  8584     iCollectionManager = new (ELeave) CCamCollectionManagerAO( *this );
  8496     
  8585     
  8497     //iStillCaptureView->Container()->MakeVisible( ETrue );
  8586     //iStillCaptureView->Container()->MakeVisible( ETrue );
  8498     ActivateLocalViewL( iStillCaptureView->Id() );
  8587 
  8499     
  8588     if( IsEmbedded() && iTargetMode == ECamControllerVideo )
       
  8589         {
       
  8590         ActivateLocalViewL( iVideoCaptureView->Id() );    
       
  8591         }
       
  8592     else        
       
  8593         {
       
  8594         ActivateLocalViewL( iStillCaptureView->Id() );
       
  8595         }    
  8500     StartCheckingDefaultAlbumIdL();
  8596     StartCheckingDefaultAlbumIdL();
  8501     PRINT( _L("Camera <= CCamAppUi::CompleteAppUIConstructionL") )
  8597     PRINT( _L("Camera <= CCamAppUi::CompleteAppUIConstructionL") )
  8502     }
  8598     }
  8503 
  8599 
  8504 // ---------------------------------------------------------
  8600 // ---------------------------------------------------------
  8673     {
  8769     {
  8674     PRINT1( _L("Camera <> CCamAppUi::PreCaptureMode %d"), iPreCaptureMode);
  8770     PRINT1( _L("Camera <> CCamAppUi::PreCaptureMode %d"), iPreCaptureMode);
  8675     return iPreCaptureMode;
  8771     return iPreCaptureMode;
  8676     }
  8772     }
  8677 
  8773 
       
  8774 void CCamAppUi::HandleServerAppExit(TInt aReason)
       
  8775     {
       
  8776     PRINT1(_L("Camera => CCamAppUi::HandleServerAppExit. aReason:%d"), aReason);
       
  8777 
       
  8778     MAknServerAppExitObserver::HandleServerAppExit(aReason);
       
  8779 
       
  8780     iVideoClipPlayInProgress = EFalse;
       
  8781     
       
  8782     PRINT(_L("Camera <= CCamAppUi::HandleServerAppExit."));
       
  8783     }
       
  8784 
       
  8785 
       
  8786 
  8678 //  End of File
  8787 //  End of File