camerauis/cameraapp/generic/src/CamAppController.cpp
branchRCL_3
changeset 9 792dfc98fb3b
parent 7 dbec5787fa68
child 10 8c55c525d5d7
equal deleted inserted replaced
7:dbec5787fa68 9:792dfc98fb3b
  3320 //
  3320 //
  3321 void 
  3321 void 
  3322 CCamAppController::IntSettingChangedL( TCamSettingItemIds aSettingItem, 
  3322 CCamAppController::IntSettingChangedL( TCamSettingItemIds aSettingItem, 
  3323                                        TInt               aSettingValue )
  3323                                        TInt               aSettingValue )
  3324   {
  3324   {
       
  3325   PRINT( _L("Camera => CCamAppController::IntSettingChangedL") );  
  3325   switch( aSettingItem )
  3326   switch( aSettingItem )
  3326     {
  3327     {
  3327     case ECamSettingItemDynamicSelfTimer:
  3328     case ECamSettingItemDynamicSelfTimer:
  3328       {
  3329       {
  3329       TCamSelfTimerFunctions function( ECamSelfTimerDisabled );
  3330       TCamSelfTimerFunctions function( ECamSelfTimerDisabled );
  3380     default:
  3381     default:
  3381       {
  3382       {
  3382       break;
  3383       break;
  3383       }
  3384       }
  3384     }
  3385     }
       
  3386   PRINT( _L("Camera <= CCamAppController::IntSettingChangedL") );
  3385   }
  3387   }
  3386 
  3388 
  3387 // ---------------------------------------------------------------------------
  3389 // ---------------------------------------------------------------------------
  3388 // CCamAppController::TextSettingChangedL
  3390 // CCamAppController::TextSettingChangedL
  3389 //
  3391 //
  4775   
  4777   
  4776   if ( iConfigManager && iConfigManager->IsKeyLockWatcherSupported() )
  4778   if ( iConfigManager && iConfigManager->IsKeyLockWatcherSupported() )
  4777       {
  4779       {
  4778       iKeyLockStatusWatcher  = CCamPropertyWatcher::NewL( *this,
  4780       iKeyLockStatusWatcher  = CCamPropertyWatcher::NewL( *this,
  4779                                                           KPSUidAvkonDomain,
  4781                                                           KPSUidAvkonDomain,
  4780                                                           KAknKeyguardStatus );      
  4782                                                           KAknKeyguardStatus );
       
  4783       // request notifications about key lock status
       
  4784       iKeyLockStatusWatcher->Subscribe();     
  4781       }
  4785       }
  4782   // read central repository value indicating whether camera shutter sound
  4786   // read central repository value indicating whether camera shutter sound
  4783   // should be played always or depending on the current profile setting
  4787   // should be played always or depending on the current profile setting
  4784   CRepository* cr = CRepository::NewLC( KCRUidCamcorderFeatures );
  4788   CRepository* cr = CRepository::NewLC( KCRUidCamcorderFeatures );
  4785   TInt value;
  4789   TInt value;
  5194   iCameraWoken = EFalse;
  5198   iCameraWoken = EFalse;
  5195     
  5199     
  5196   TBool continueWithCapture = ETrue;
  5200   TBool continueWithCapture = ETrue;
  5197   CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );  
  5201   CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );  
  5198   
  5202   
  5199   // Capture needed as fast as possible.
  5203   // Cancel capture if there are settings pending
  5200   // Use direct stopping of viewfinder
  5204   if ( IsFlagOn( iBusyFlags, EBusySetting ) )
  5201   // unless there are settings pending,
       
  5202   // otherwise cancel capture
       
  5203   if ( !IsFlagOn( iBusyFlags, EBusySetting ) )
       
  5204       {
       
  5205       // Stop VF for burst mode or for secondary or
       
  5206       // embedded camera before capturing.
       
  5207       // VF stopping will increase capture lag.
       
  5208       if ( iInfo.iImageMode == ECamImageCaptureBurst ||
       
  5209            iInfo.iActiveCamera == ECamActiveCameraSecondary ||
       
  5210            appUi->IsEmbedded() )
       
  5211           {
       
  5212           StopViewFinder();
       
  5213           }
       
  5214       }
       
  5215   else
       
  5216       {
  5205       {
  5217       continueWithCapture = EFalse;
  5206       continueWithCapture = EFalse;
  5218       }
  5207       }
  5219   
       
  5220 
  5208 
  5221   switch( iInfo.iImageMode )
  5209   switch( iInfo.iImageMode )
  5222     {
  5210     {
  5223     // -----------------------------------------------------
  5211     // -----------------------------------------------------
  5224     // Burst capture
  5212     // Burst capture
  7793       else
  7781       else
  7794           {
  7782           {
  7795           (void)aCategory;
  7783           (void)aCategory;
  7796           (void)aKey;
  7784           (void)aKey;
  7797           }
  7785           }
  7798 
  7786       }
  7799       }
  7787       
       
  7788       // if its key lock state changed
       
  7789       if ( aCategory == KPSUidAvkonDomain && aKey == KAknKeyguardStatus )
       
  7790           {
       
  7791           PRINT( _L("Camera <> aCategory == KPSUidAvkonDomain && aKey == KAknKeyguardStatus") );
       
  7792           if ( !IsKeyLockOn() )
       
  7793               {
       
  7794               PRINT( _L("Camera <> !IsKeyLockOn()") );
       
  7795               // if in standby view and the slide is opened then exit standby view
       
  7796               CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
  7797               TVwsViewId activeView;
       
  7798               appUi->GetActiveViewId( activeView );
       
  7799               CCamPreCaptureViewBase* view = static_cast<CCamPreCaptureViewBase*>( appUi->View( activeView.iViewUid ) );
       
  7800               if ( iInfo.iOperation == ECamStandby ||
       
  7801                    ( view && view->IsInStandbyMode() ) )
       
  7802                   {
       
  7803                    PRINT( _L("Camera HandleSlideOpenedL => Exit Standby view") );
       
  7804                    view->HandleCommandL( ECamCmdExitStandby );
       
  7805                   }
       
  7806               }
       
  7807           }
       
  7808 
       
  7809 
  7800 #endif // !( defined(__WINS__) || defined(__WINSCW__        
  7810 #endif // !( defined(__WINS__) || defined(__WINSCW__        
  7801 
  7811 
  7802   PRINT( _L("Camera <= CCamAppController::HandlePropertyChangedL"))
  7812   PRINT( _L("Camera <= CCamAppController::HandlePropertyChangedL"))
  7803 
  7813 
  7804   }                             
  7814   }                             
  8672 				iLocationTrailTimer->SetTimeout( KLocTrailCloseRetryTime );
  8682 				iLocationTrailTimer->SetTimeout( KLocTrailCloseRetryTime );
  8673 	    		}
  8683 	    		}
  8674 	    	iLocationTrailTimer->StartTimer();
  8684 	    	iLocationTrailTimer->StartTimer();
  8675 			}
  8685 			}
  8676 		}
  8686 		}
       
  8687       else if ( aCloseSession ) 
       
  8688         {
       
  8689 		PRINT( _L("Camera => CCamAppController::StartLocationTrailL - iLocationUtility.Close()") );
       
  8690         // location trail already stopped, but we are exiting app, so close the utility
       
  8691 		iLocationUtility.Close();
       
  8692 		iLocationUtilityConnected = EFalse;
       
  8693 		}
       
  8694 
  8677 	#endif
  8695 	#endif
  8678 	  PRINT( _L("Camera <= CCamAppController::StopLocationTrail") );
  8696 	  PRINT( _L("Camera <= CCamAppController::StopLocationTrail") );
  8679 	  }
  8697 	  }
  8680 
  8698 
  8681 // ---------------------------------------------------------------------------
  8699 // ---------------------------------------------------------------------------
  8849           if( iConfigManager && iConfigManager->IsUIOrientationOverrideSupported() )
  8867           if( iConfigManager && iConfigManager->IsUIOrientationOverrideSupported() )
  8850               {
  8868               {
  8851               NotifyControllerObservers( ECamEventInitReady );
  8869               NotifyControllerObservers( ECamEventInitReady );
  8852               }
  8870               }
  8853           }
  8871           }
  8854       
  8872 
  8855       if ( UiConfigManagerPtr()->IsLocationSupported() &&
  8873       if ( UiConfigManagerPtr()->IsLocationSupported() )
  8856                    !appUi->IsEmbedded())
  8874         {
  8857               {
  8875         if( ECamLocationOn == IntegerSettingValue( ECamSettingItemRecLocation ) )
  8858               if( ECamLocationOn == IntegerSettingValue( ECamSettingItemRecLocation ) )
  8876             {
  8859                   {
  8877             if( ECamActiveCameraPrimary == ActiveCamera())
  8860                   if( ECamActiveCameraPrimary == ActiveCamera() && ECamStandby != CurrentOperation() )
  8878                 {
  8861                       {
  8879                 StartLocationTrailL();
  8862                       StartLocationTrailL();
  8880                 }
  8863                       }
  8881             else // Secondary camera 
  8864                   else // Secondary camera 
  8882                 {
  8865                       {
  8883                 PRINT( _L("Camera: CCamAppController::HandleCameraEventL - secondary camera, stop location trail") )
  8866                       PRINT( _L("Camera: CCamAppController::HandleCameraEventL - secondary camera, stop location trail") )
  8884                 StopLocationTrail();
  8867                       StopLocationTrail();
  8885                 }
  8868                       }
  8886             }
  8869                   }
  8887         }
  8870               }
  8888 
  8871       break;
  8889       break;
  8872       }
  8890       }
  8873     case ECamCameraEventVfFrameReady:
  8891     case ECamCameraEventVfFrameReady:
  8874       {      
  8892       {      
  8875       HandleViewfinderFrame( aStatus, static_cast<CFbsBitmap*>( aEventData ) );
  8893       HandleViewfinderFrame( aStatus, static_cast<CFbsBitmap*>( aEventData ) );
  8985       {
  9003       {
  8986       if( !Busy() )
  9004       if( !Busy() )
  8987         {
  9005         {
  8988         PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - Issue new recovery sequence" ) );
  9006         PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - Issue new recovery sequence" ) );
  8989         SetStateFromEvent( ECamCameraEventReserveLose );  
  9007         SetStateFromEvent( ECamCameraEventReserveLose );  
  8990         SetTargetMode( ECamControllerImage );
  9008         CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
  8991         SetTargetImageMode( CurrentImageModeSetup() );
  9009         // Find target mode from appUi and set this controller target mode 
       
  9010         if( appUi->TargetMode() ==  ECamControllerVideo )
       
  9011             {
       
  9012             PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - recover to video mode" ) );
       
  9013             SetTargetMode( ECamControllerVideo  );
       
  9014             SetTargetImageMode( ECamImageCaptureNone );
       
  9015             }
       
  9016         else
       
  9017             {
       
  9018             PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - recover to still mode" ) );
       
  9019             SetTargetMode( ECamControllerImage );
       
  9020             SetTargetImageMode( CurrentImageModeSetup() );
       
  9021             }
  8992         IssueModeChangeSequenceL();
  9022         IssueModeChangeSequenceL();
  8993         }
  9023         }
  8994       else
  9024       else
  8995         {
  9025         {
  8996         PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - Recovery sequence is active" ) );
  9026         PRINT( _L( "Camera => CCamAppController::HandleCameraEventL - Recovery sequence is active" ) );
  9533     // =================================
  9563     // =================================
  9534     case ECamCameraEventReserveLose:
  9564     case ECamCameraEventReserveLose:
  9535       // SetMode( ECamControllerShutdown );
  9565       // SetMode( ECamControllerShutdown );
  9536       SetMode( ECamControllerIdle );
  9566       SetMode( ECamControllerIdle );
  9537       SetOperation( ECamNoOperation );
  9567       SetOperation( ECamNoOperation );
       
  9568       // we dont need location trail anymore.
       
  9569       StopLocationTrail();
  9538       break;
  9570       break;
  9539     // ---------------------------------
  9571     // ---------------------------------
  9540     case ECamCameraEventPowerOn:
  9572     case ECamCameraEventPowerOn:
  9541       PRINT( _L("Camera <> Init key sound system..") );
  9573       PRINT( _L("Camera <> Init key sound system..") );
  9542       iSoundPlayer->InitKeySoundSystem();
  9574       iSoundPlayer->InitKeySoundSystem();
 10930 //  
 10962 //  
 10931 void CCamAppController::StoreUserSceneSettingsL()
 10963 void CCamAppController::StoreUserSceneSettingsL()
 10932     {
 10964     {
 10933     iSettingsModel->StoreUserSceneSettingsL();	    
 10965     iSettingsModel->StoreUserSceneSettingsL();	    
 10934     }      
 10966     }      
       
 10967 
       
 10968 // ---------------------------------------------------------------------------
       
 10969 // HandleVideoQualitySettingChangeL
       
 10970 // ---------------------------------------------------------------------------
       
 10971 //
       
 10972 void 
       
 10973 CCamAppController::HandleVideoQualitySettingChangeL() 
       
 10974   {
       
 10975   PRINT( _L("Camera => CCamAppController::HandleVideoQualitySettingChangeL") );
       
 10976   if( IsViewFinding() && !Busy() ) 
       
 10977     {
       
 10978     PRINT( _L("Camera <> CCamAppController - viewfinder on, stop vf / re-prepare / start vf..") );
       
 10979     TRAPD( status, 
       
 10980       {
       
 10981       // Synchronous items
       
 10982       // IssueDirectRequestL( ECamRequestVfStop    );
       
 10983       // IssueDirectRequestL( ECamRequestSsRelease );
       
 10984       // IssueRequestL( ECamRequestVideoInit );
       
 10985       // IssueDirectRequestL( ECamRequestSsStart   );
       
 10986       // IssueDirectRequestL( ECamRequestVfStart   );
       
 10987 
       
 10988       // Generate the request sequence and issue to Camera Controller.
       
 10989       RCamRequestArray sequence;
       
 10990       CleanupClosePushL( sequence );
       
 10991 
       
 10992       // Asynchronously init video. No need to reconstruct video names etc.
       
 10993       sequence.Append( ECamRequestVfStop );
       
 10994       sequence.Append( ECamRequestSsRelease );
       
 10995       
       
 10996       SetVideoInitNeeded( ETrue );
       
 10997 
       
 10998       sequence.Append( ECamRequestVideoRelease );
       
 10999       sequence.Append( ECamRequestVideoInit );
       
 11000 
       
 11001       sequence.Append( ECamRequestSsStart );
       
 11002       sequence.Append( ECamRequestVfStart );
       
 11003 
       
 11004       // Set busy flags to indicate sequence in progress and execute the seq 
       
 11005       SetFlags( iBusyFlags, EBusySequence );
       
 11006       TCleanupItem clearBusy( ClearSequenceBusyFlag, &iBusyFlags );
       
 11007       CleanupStack::PushL( clearBusy );
       
 11008       iCameraController->RequestSequenceL( sequence );
       
 11009       CleanupStack::Pop();
       
 11010    
       
 11011       iCaptureModeTransitionInProgress = ETrue;
       
 11012       CleanupStack::PopAndDestroy(); // sequence.Close()
       
 11013       });
       
 11014 
       
 11015     if( KErrNone != status )
       
 11016       {
       
 11017       PRINT1( _L("Camera <> CCamAppController::HandleVideoQualitySettingChangeL, error:%d"), status );
       
 11018       SetOperation( ECamStandby, status );
       
 11019       }
       
 11020     }
       
 11021 
       
 11022   PRINT( _L("Camera <= CCamAppController::HandleVideoQualitySettingChangeL") );
       
 11023   }
       
 11024 
       
 11025 // ---------------------------------------------------------------------------
       
 11026 // CCamAppController::ToggleWideScreenQuality
       
 11027 // Toggles between wide-screen (16:9) and VGA (4:3) screen resolutions.
       
 11028 // Applicable only for highest quality settings for 16:9 & 4:3.
       
 11029 // ---------------------------------------------------------------------------
       
 11030 //
       
 11031 TBool CCamAppController::ToggleWideScreenQuality( TBool aWide )
       
 11032     {
       
 11033     TBool qualityChanged = EFalse;
       
 11034     
       
 11035     if ( ECamControllerImage == iInfo.iMode && ECamActiveCameraPrimary == iInfo.iActiveCamera )
       
 11036         {
       
 11037         PRINT( _L("Camera => CCamAppController::ToggleWideScreenQuality - image mode") );
       
 11038         TInt qualityIndex = IntegerSettingValue( ECamSettingItemPhotoQuality );
       
 11039         if ( qualityIndex <= ECamImageQualityPrintW9m )
       
 11040             {
       
 11041             TCamPhotoQualitySetting imageQuality = iConfiguration->ImageQuality( qualityIndex );
       
 11042             if ( ( imageQuality.iPhotoResolution == EImageResolution12MP &&  aWide ) || 
       
 11043                  ( imageQuality.iPhotoResolution == EImageResolutionW9MP && !aWide ) )
       
 11044                 {
       
 11045                 qualityIndex = (ECamImageQualityPrintW9m==qualityIndex) ? ECamImageQualityPrint12m 
       
 11046                                                                         : ECamImageQualityPrintW9m;
       
 11047 
       
 11048                 // Ensure that the setting value is enabled/usable.
       
 11049                 if ( iSettingsModel->SettingValueEnabled( ECamSettingItemPhotoQuality, qualityIndex ) )
       
 11050                     {
       
 11051                     SetIntegerSettingValueL( ECamSettingItemPhotoQuality, qualityIndex );
       
 11052                     qualityChanged = ETrue;
       
 11053                     }
       
 11054                 }
       
 11055             else
       
 11056                 ; // skip
       
 11057             }
       
 11058         PRINT( _L("Camera <= CCamAppController::ToggleWideScreenQuality") );
       
 11059         }
       
 11060     else if ( ECamControllerVideo == iInfo.iMode && ECamActiveCameraPrimary == iInfo.iActiveCamera ) 
       
 11061         {
       
 11062         PRINT( _L("Camera => CCamAppController::ToggleWideScreenQuality - video mode") );        
       
 11063         TInt qualityIndex = IntegerSettingValue( ECamSettingItemVideoQuality );
       
 11064         if ( qualityIndex <= ECamVideoQualityNormalHigh )
       
 11065             {
       
 11066             TVideoQualitySettings videoQuality = iConfiguration->VideoQuality( qualityIndex );
       
 11067             qualityIndex = (ECamVideoQualityNormalHigh==qualityIndex) ? ECamVideoQualityHigh
       
 11068                                                                       : ECamVideoQualityNormalHigh;
       
 11069 
       
 11070             if ( ( videoQuality.iVideoResolution == ECamVideoResolutionVGA &&  aWide ) || 
       
 11071                  ( videoQuality.iVideoResolution == ECamVideoResolutionHD  && !aWide ) )
       
 11072                 {
       
 11073                 // Ensure that the setting value is enabled/usable.
       
 11074                 if ( iSettingsModel->SettingValueEnabled( ECamSettingItemVideoQuality, qualityIndex ) )
       
 11075                     {
       
 11076                     SetIntegerSettingValueL( ECamSettingItemVideoQuality, qualityIndex );
       
 11077                     HandleVideoQualitySettingChangeL();
       
 11078                     qualityChanged = ETrue;
       
 11079                     }
       
 11080                 }
       
 11081             }
       
 11082         PRINT( _L("Camera <= CCamAppController::ToggleWideScreenQuality") );
       
 11083         }
       
 11084     else // avoids LINT warning.
       
 11085         PRINT( _L("Camera =><= CCamAppController::ToggleWideScreenQuality - current quality level NOT high") );
       
 11086 
       
 11087     return qualityChanged;
       
 11088     }
       
 11089 
 10935 //  End of File  
 11090 //  End of File  
       
 11091