camerauis/cameraapp/generic/src/CamAppui.cpp
branchRCL_3
changeset 25 bf64cebf4673
parent 20 38fb6f7eacd5
child 27 53c8aa5d97a3
--- a/camerauis/cameraapp/generic/src/CamAppui.cpp	Tue Apr 27 16:19:06 2010 +0300
+++ b/camerauis/cameraapp/generic/src/CamAppui.cpp	Tue May 11 15:56:11 2010 +0300
@@ -95,7 +95,7 @@
 #include "CameraVariant.hrh"
 #include "OstTraceDefinitions.h"
 #ifdef OST_TRACE_COMPILER_IN_USE
-#include "CamAppUiTraces.h"
+#include "CamAppuiTraces.h"
 #endif
 #include "camactivepalettehandler.h"
 #include "CamContainerBase.h"
@@ -593,6 +593,7 @@
     {  
     PRINT( _L("Camera => CCamAppUi::ConstructL create doc handler") );
     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
+    iDocHandler->SetExitObserver(this);
   iController.CheckMemoryToUseL();
   
     // create navi-pane and navi-porgress bar for use in camcorder mode 
@@ -1234,6 +1235,16 @@
     case EEikCmdExit: // fallthrough
     case EAknSoftkeyExit:
       {
+      CAknToolbar* fixedToolbar = CurrentFixedToolbar();
+      if ( fixedToolbar )
+        {
+        CAknToolbarExtension* extension = fixedToolbar->ToolbarExtension();
+        if ( extension )
+            {
+            extension->SetShown( EFalse );
+            }
+        fixedToolbar->SetToolbarVisibility( EFalse );
+        } 
       OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP3_CCAMAPPUI_HANDLECOMMANDL, "e_ExternalExit 1" );
       PRINT( _L("Camera CCamAppUi external exit call") );
       if ( iEikonEnv->StartedAsServerApp() )
@@ -1684,10 +1695,24 @@
     // -----------------------------------------------------
     case ECamCmdPlay:   
       {
-      TDataType dataType;
-      SetEmbedding( ETrue );
-      iDocHandler->OpenFileEmbeddedL( iController.CurrentFullFileName(),
-                                      dataType );
+      PRINT1(_L("Camera <=> CCamAppUi::HandleCommandL. case ECamCmdPlay, iVideoClipPlayInProgress:%d"), iVideoClipPlayInProgress);
+      
+      if ( !iVideoClipPlayInProgress)
+        {
+        TDataType dataType;
+        TInt           err;
+         
+        SetEmbedding( ETrue );
+        
+        err = iDocHandler->OpenFileEmbeddedL( iController.CurrentFullFileName(),  dataType );
+        PRINT1(_L("Camera <=> CCamAppUi::HandleCommandL. iDocHandler ->OpenFileEmbeddedL err:%d"), err);
+        
+        if ( KErrNone == err)
+            {
+            iVideoClipPlayInProgress = ETrue;
+            }
+        }  
+      
       }
       break;
      // -----------------------------------------------------
@@ -1973,13 +1998,17 @@
       if( iFirstBoot )
           {	
           PRINT( _L( "Camera <> CCamAppUi::HandleCameraEventL ECamCameraEventReserveRequested/ECamCameraEventPowerOnRequested" ) )	
-          if ( iWaitTimer->IsActive() )
+          // in embedded mode appui construct timer started already
+          if ( !IsEmbedded() )
               {
-              PRINT( _L( "Camera <> timer already active" ) )
-              iWaitTimer->Cancel();
+              if ( iWaitTimer->IsActive() )
+                  {
+                  PRINT( _L( "Camera <> timer already active" ) )
+                  iWaitTimer->Cancel();
+                  }
+              PRINT( _L( "Camera <> start the appui construct timer" ) )
+              iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );  
               }
-          PRINT( _L( "Camera <> start the appui construct timer" ) )
-          iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );  
           }
       else
           {
@@ -3207,11 +3236,26 @@
               }
   
           // Free the needed ram memory if not enough available
-          iMemoryMonitor->CheckAndRequestMemoryL(
+          TInt memError = iMemoryMonitor->CheckAndRequestMemoryL(
                            iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained(),
                            iController.UiConfigManagerPtr()->RequiredRamMemoryFocusGained(),
                            EFalse );
 
+          TInt freeMemory = 0;
+          TInt halerror=HAL::Get( HALData::EMemoryRAMFree, freeMemory );
+          if( halerror != KErrNone )
+              {
+              User::Leave( halerror );          
+              }
+          
+          if ( memError && freeMemory < iController.UiConfigManagerPtr()->CriticalLevelRamMemoryFocusGained() )
+              {
+              PRINT( _L("Camera <> CCamAppUi::HandleWsEvent ECamEventFocusGained memory too low. Exiting") );
+              CloseAppL();
+              PRINT( _L("Camera <= CCamAppUi::HandleWsEvent ECamEventFocusGained memory too low. Exiting") );
+              return;
+              }
+
 
           iController.SetEndKeyExitWaiting( EFalse );
           //Don't update task state in case of embedded camera
@@ -3329,6 +3373,14 @@
               RaisePreCaptureCourtesyUI( ETrue );
               }
           
+          //We hiden toolbar when keylock was set to on in pre-capture view and camera lost focus, 
+          //so we need to display toolbar when keylock is set to off and camera gain focus again.
+          if ( ECamViewStatePreCapture == iViewState &&
+               ECamPreCapViewfinder == iPreCaptureMode )  
+            {
+            SetToolbarVisibility(); 
+            }          
+          
           // If keylock is set on when recording is starting up but not yet 
           // started, display toolbar when keylock is set off since we are 
           // returning to precapture view, unless capturing is still going on.
@@ -3371,6 +3423,15 @@
               {
               SubmergeToolbar();
               }
+              
+          //We need hiding the toolbar if keylock is set to on in pre-catpure view, 
+          //otherwise the toolbar will be displayed when press volume key in keylock on status.
+          if ( iController.IsKeyLockOn() &&
+               ECamViewStatePreCapture == iViewState && 
+               ECamPreCapViewfinder == iPreCaptureMode ) 
+            {
+            SubmergeToolbar(); 
+            }
 
           // focus lost event while videocall active and camera in standby,
           // no notification to views
@@ -6134,11 +6195,23 @@
 CCamAppUi::StartAsServerAppL( MCamEmbeddedObserver* aEmbeddedObserver, 
                               TInt                  aMode )
     {       
-    PRINT( _L("Camera => CCamAppUi::StartAsServerAppL") );  
+    PRINT1( _L("Camera => CCamAppUi::StartAsServerAppL mode:%d"), aMode );  
 
     __ASSERT_ALWAYS( aMode == ECamControllerVideo || aMode == ECamControllerImage, 
             CamPanic( ECamPanicNotSupported ) );
 
+    // start the ui construct timer to speed up the starting in embedded mode
+    if ( iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
+        {
+        if ( iWaitTimer->IsActive() )
+            {
+            PRINT( _L( "Camera <> timer already active" ) )
+            iWaitTimer->Cancel();
+            }
+        PRINT( _L( "Camera <> start the appui construct timer" ) )
+        iWaitTimer->Start( 0, 0,  TCallBack( AppUIConstructCallbackL, this ) );
+        }
+
     // Load Embedded Settings
     iController.LoadStaticSettingsL( ETrue );
     iEmbeddedViewSet = ETrue;     
@@ -6149,10 +6222,12 @@
     if ( aMode == ECamControllerVideo )
         {
         iTargetMode = ECamControllerVideo;
+        iMode = ECamControllerVideo;
         }
     else if ( aMode == ECamControllerImage )
         {
         iTargetMode = ECamControllerImage;
+        iMode = ECamControllerImage;
         }
 
     // Find the parent app's name:
@@ -6244,7 +6319,9 @@
     iViewState = ECamViewStatePreCapture;    
   iTargetViewState = ECamViewStatePreCapture;   	
     TrySwitchViewL();                                      
-
+    
+    // Start reserve-poweron sequence
+    iController.EmbeddedStartupSequence();
 
     PRINT( _L("Camera <= CCamAppUi::StartAsServerAppL") );
     }
@@ -7523,6 +7600,7 @@
             if ( iController.IsTouchScreenSupported() )
                 {
                 precapView->CreateAndSetToolbarL( R_CAM_EMPTY_FIXED_TOOLBAR );
+                SetToolbarVisibility();
                 }
             EikSoftkeyPostingTransparency::MakeTransparent(
                 *precapView->ViewCba(), EFalse );
@@ -8441,9 +8519,19 @@
   
     ConstructNaviPaneL();
     
-    //always start in stillmode
-    SetDefaultViewL( *iStillCaptureView );
-        
+
+    //embedded camera may start straight in videomode
+    if( IsEmbedded() && iTargetMode == ECamControllerVideo )
+        {
+        SetDefaultViewL( *iVideoCaptureView );
+        PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL SetDefaultView Video") );
+        }
+    else
+        {
+        SetDefaultViewL( *iStillCaptureView );
+        PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL SetDefaultView Still") );
+        }
+                
     // pre-construct side-pane & zoom pane
     // get whether we overlay sidepane over view-finder
     TBool overlayViewFinder;
@@ -8458,6 +8546,7 @@
   
     PRINT( _L("Camera <> CCamAppUi::CompleteAppUIConstructionL create doc handler") );
     iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
+    iDocHandler->SetExitObserver(this);    
 
     // Check to see if we are set to use mmc storage but the card has
     // been removed.  
@@ -8495,8 +8584,15 @@
     iCollectionManager = new (ELeave) CCamCollectionManagerAO( *this );
     
     //iStillCaptureView->Container()->MakeVisible( ETrue );
-    ActivateLocalViewL( iStillCaptureView->Id() );
-    
+
+    if( IsEmbedded() && iTargetMode == ECamControllerVideo )
+        {
+        ActivateLocalViewL( iVideoCaptureView->Id() );    
+        }
+    else        
+        {
+        ActivateLocalViewL( iStillCaptureView->Id() );
+        }    
     StartCheckingDefaultAlbumIdL();
     PRINT( _L("Camera <= CCamAppUi::CompleteAppUIConstructionL") )
     }
@@ -8675,4 +8771,17 @@
     return iPreCaptureMode;
     }
 
+void CCamAppUi::HandleServerAppExit(TInt aReason)
+    {
+    PRINT1(_L("Camera => CCamAppUi::HandleServerAppExit. aReason:%d"), aReason);
+
+    MAknServerAppExitObserver::HandleServerAppExit(aReason);
+
+    iVideoClipPlayInProgress = EFalse;
+    
+    PRINT(_L("Camera <= CCamAppUi::HandleServerAppExit."));
+    }
+
+
+
 //  End of File