camerauis/cameraapp/generic/src/CamAppController.cpp
branchRCL_3
changeset 67 756ad29ed18e
parent 62 f0c0788c4de2
equal deleted inserted replaced
62:f0c0788c4de2 67:756ad29ed18e
   591   PRINT( _L("Camera <> delete Configuration Manager..") );
   591   PRINT( _L("Camera <> delete Configuration Manager..") );
   592   delete iConfiguration;
   592   delete iConfiguration;
   593   iConfiguration = NULL;  
   593   iConfiguration = NULL;  
   594 
   594 
   595   RProperty::Delete( KPSUidCamcorderNotifier, KCCorFocused );  
   595   RProperty::Delete( KPSUidCamcorderNotifier, KCCorFocused );  
   596   if( TUid::Null() != iPlugin )
   596     if( iPlugin )
   597       {
   597         {
   598       // Destroy Ecom plugin
   598         // Destroy Ecom plugin
   599       REComSession::DestroyedImplementation( iPlugin );    
   599         iPlugin->DestroyPlugin();
   600       REComSession::FinalClose();
   600         }
   601       }
   601   iPlugin = NULL;
   602   delete iDriveChangeNotifier;
   602   delete iDriveChangeNotifier;
   603   iFs.Close();
   603   iFs.Close();
   604   
   604   
   605   if( iRotatorAo )
   605   if( iRotatorAo )
   606       {
   606       {
   607       delete iRotatorAo;
   607       delete iRotatorAo;
   608       }
   608       }
   609 
   609 
   610   delete iSnapShotRotator;
   610   delete iSnapShotRotator;
       
   611 
       
   612   if( iRotatedSnapshot )
       
   613       {
       
   614       delete iRotatedSnapshot;
       
   615       }
   611   
   616   
   612   if( iTvAccessoryMonitor )
   617   if( iTvAccessoryMonitor )
   613       {
   618       {
   614       delete iTvAccessoryMonitor;
   619       delete iTvAccessoryMonitor;
   615       iTvAccessoryMonitor = NULL;
   620       iTvAccessoryMonitor = NULL;
  1230     if( appUi->SettingsLaunchedFromCamera() || iDismountPending )
  1235     if( appUi->SettingsLaunchedFromCamera() || iDismountPending )
  1231         {
  1236         {
  1232         // In case settings plugin is being run or mmc dismount is pending
  1237         // In case settings plugin is being run or mmc dismount is pending
  1233         // due to usb activation, we calculate the remaining time here, 
  1238         // due to usb activation, we calculate the remaining time here, 
  1234         // instead of repreparing the engine and getting it from there  
  1239         // instead of repreparing the engine and getting it from there  
  1235         TRAPD( err, iVideoTimeRemaining = CalculateVideoTimeRemainingL( static_cast < TCamMediaStorage >(CurrentVideoStorageLocation()) ) );
  1240         TRAPD( err, iVideoTimeRemaining = CalculateVideoTimeRemainingL() );
  1236         if( KErrNone != err )
  1241         if( KErrNone != err )
  1237             {
  1242             {
  1238             iVideoTimeRemaining = 0;
  1243             iVideoTimeRemaining = 0;
  1239             }
  1244             }
  1240         }
  1245         }
  1249             iVideoTimeRemaining = RemainingVideoRecordingTime();  
  1254             iVideoTimeRemaining = RemainingVideoRecordingTime();  
  1250             }
  1255             }
  1251         else 
  1256         else 
  1252             {
  1257             {
  1253             PRINT( _L("Camera <> CCamAppController::RecordTimeRemaining - video mode not yet initialized" ));
  1258             PRINT( _L("Camera <> CCamAppController::RecordTimeRemaining - video mode not yet initialized" ));
  1254             TRAPD( err, iVideoTimeRemaining = CalculateVideoTimeRemainingL( static_cast < TCamMediaStorage >(CurrentVideoStorageLocation()) ) );
  1259             TRAPD( err, iVideoTimeRemaining = CalculateVideoTimeRemainingL() );
  1255             if( KErrNone != err )
  1260             if( KErrNone != err )
  1256                 {
  1261                 {
  1257                 iVideoTimeRemaining = 0;
  1262                 iVideoTimeRemaining = 0;
  1258                 }
  1263                 }
  1259             }
  1264             }
  2051         iSoundPlayer->EnableAllKeySounds();
  2056         iSoundPlayer->EnableAllKeySounds();
  2052         }
  2057         }
  2053   // Keep track of the fact we are now leaving saving state
  2058   // Keep track of the fact we are now leaving saving state
  2054   iSaving = EFalse;
  2059   iSaving = EFalse;
  2055   
  2060   
  2056   //create thumbnail before harvesting
  2061   // try closing video record to free up resources
  2057   if( iConfigManager && iConfigManager->IsThumbnailManagerAPISupported() )
  2062   // Test - <eo> commented out, no such direct request supported
  2058       {
  2063   // TRAP_IGNORE( IssueDirectRequestL( ECamRequestVideoRelease ) );
  2059       TRAP_IGNORE( iImageSaveActive->CreateThumbnailsL( *BurstCaptureArray() ) ;
  2064   
  2060                    iImageSaveActive->DoCreateThumbnailL() );
  2065   // if video post capture is off then force re-prepare so
  2061       }
  2066   // that remaining record time is updated
  2062         
  2067   // REMOVED
       
  2068 
       
  2069   // if using direct viewfinding pause viewfinder
       
  2070   // REMOVED
       
  2071 
  2063   // report to LifeBlog
  2072   // report to LifeBlog
  2064   RProperty::Set( KPSUidCamcorderNotifier, KCamLatestFilePath, iSuggestedVideoPath ); 
  2073   RProperty::Set( KPSUidCamcorderNotifier, KCamLatestFilePath, iSuggestedVideoPath ); 
  2065   // Add to album if this is enabled for videos
  2074   // Add to album if this is enabled for videos
  2066   TUint32 defaultAlbumId = static_cast<TUint32>( 
  2075   TUint32 defaultAlbumId = static_cast<TUint32>( 
  2067               IntegerSettingValue( ECamSettingItemDefaultAlbumId ));       
  2076               IntegerSettingValue( ECamSettingItemDefaultAlbumId ));       
  2072     }
  2081     }
  2073   else // Harvest the file but dont add to the default album
  2082   else // Harvest the file but dont add to the default album
  2074     {
  2083     {
  2075     iImageSaveActive->AddToAlbum( iSuggestedVideoPath, EFalse, defaultAlbumId );
  2084     iImageSaveActive->AddToAlbum( iSuggestedVideoPath, EFalse, defaultAlbumId );
  2076     }
  2085     }
  2077       
  2086 
       
  2087   //create thumbnail
       
  2088   if( iConfigManager && iConfigManager->IsThumbnailManagerAPISupported() )
       
  2089       {
       
  2090       TRAP_IGNORE( iImageSaveActive->CreateThumbnailsL( *BurstCaptureArray() ) );
       
  2091       }
  2078   NotifyControllerObservers( ECamEventRecordComplete,   aStatus );
  2092   NotifyControllerObservers( ECamEventRecordComplete,   aStatus );
  2079   SetOperation( ECamNoOperation );
  2093   SetOperation( ECamNoOperation );
  2080   PRINT( _L( "Camera <> calling HandleCaptureCompletion.." ) )        
  2094   PRINT( _L( "Camera <> calling HandleCaptureCompletion.." ) )        
  2081   HandleCaptureCompletion();
  2095   HandleCaptureCompletion();
  2082   NotifyControllerObservers( ECamEventMediaFileChanged, aStatus );
  2096   NotifyControllerObservers( ECamEventMediaFileChanged, aStatus );
  2550   CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
  2564   CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
  2551   iCameraController->SwitchCameraL( (ECamActiveCameraPrimary == targetCamera) ? 0 : 1 );
  2565   iCameraController->SwitchCameraL( (ECamActiveCameraPrimary == targetCamera) ? 0 : 1 );
  2552   if( UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
  2566   if( UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
  2553       {
  2567       {
  2554       RArray<TInt> screenModeValues;
  2568       RArray<TInt> screenModeValues;
  2555       CleanupClosePushL( screenModeValues );
       
  2556       UiConfigManagerPtr()->SupportedScreenModesL( screenModeValues );
  2569       UiConfigManagerPtr()->SupportedScreenModesL( screenModeValues );
  2557       TInt landscapeScreenMode = screenModeValues[0];
  2570       TInt landscapeScreenMode = screenModeValues[0];
  2558       SetCameraOrientationModeL( landscapeScreenMode );
  2571       SetCameraOrientationModeL( landscapeScreenMode );
  2559       CleanupStack::PopAndDestroy( &screenModeValues );
       
  2560       }
  2572       }
  2561   iCameraController->CompleteSwitchCameraL();
  2573   iCameraController->CompleteSwitchCameraL();
  2562   // Force to get a sensor data after switch camera from primary to secondary 
       
  2563   // when always holding in camera with portrait mode. 
       
  2564   if( iConfigManager 
       
  2565       && iConfigManager->IsOrientationSensorSupported() )
       
  2566     {
       
  2567     if( iAccSensorListening )
       
  2568       {
       
  2569       iAccSensorListening = EFalse;
       
  2570       }
       
  2571     if( iAccSensorChannel )
       
  2572       {
       
  2573       delete iAccSensorChannel;
       
  2574       iAccSensorChannel = NULL;
       
  2575       }        
       
  2576     TRAP_IGNORE( UpdateSensorApiL( ETrue ) );            
       
  2577     }
       
  2578 
  2574 
  2579   // Camera switched.
  2575   // Camera switched.
  2580   // a) Set current camera index to the new one.
  2576   // a) Set current camera index to the new one.
  2581   // b) Set target mode (video/image) to the one before mode switch.
  2577   // b) Set target mode (video/image) to the one before mode switch.
  2582   // c) Image mode is single shot after camera switch
  2578   // c) Image mode is single shot after camera switch
  4007 // Returns true if AppUi has been constructed, and not yet destructed
  4003 // Returns true if AppUi has been constructed, and not yet destructed
  4008 // ---------------------------------------------------------------------------
  4004 // ---------------------------------------------------------------------------
  4009 //
  4005 //
  4010 TBool CCamAppController::IsAppUiAvailable() const
  4006 TBool CCamAppController::IsAppUiAvailable() const
  4011     {
  4007     {
  4012     PRINT1(_L("Camera <> CCamAppController::IsAppUiAvailable=%d"),iAppUiAvailable);
       
  4013     return iAppUiAvailable;
  4008     return iAppUiAvailable;
  4014     }       
  4009     }       
  4015     
  4010     
  4016 // ---------------------------------------------------------------------------
  4011 // ---------------------------------------------------------------------------
  4017 // CCamAppController::SetAppUiAvailable
  4012 // CCamAppController::SetAppUiAvailable
  4784   , iDiskCriticalLevel   ( KErrNotFound )
  4779   , iDiskCriticalLevel   ( KErrNotFound )
  4785   , iRamDiskCriticalLevel( KErrNotFound )
  4780   , iRamDiskCriticalLevel( KErrNotFound )
  4786   , iImageOrientation( ECamOrientation0 )
  4781   , iImageOrientation( ECamOrientation0 )
  4787   , iLastImageOrientation( ECamOrientation0 )
  4782   , iLastImageOrientation( ECamOrientation0 )
  4788   , iLongIdleTimeout( KIdleTimeout * 5 )
  4783   , iLongIdleTimeout( KIdleTimeout * 5 )
  4789   , iPlugin( TUid::Null() )
       
  4790   , iPendingHdmiEvent( ECamHdmiNoEvent )
  4784   , iPendingHdmiEvent( ECamHdmiNoEvent )
  4791   {
  4785   {
  4792   }
  4786   }
  4793 
  4787 
  4794 // ---------------------------------------------------------------------------
  4788 // ---------------------------------------------------------------------------
  8544 //  
  8538 //  
  8545 void CCamAppController::HandleCaptureCompletion()
  8539 void CCamAppController::HandleCaptureCompletion()
  8546   {
  8540   {
  8547   PRINT( _L( "Camera => CCamAppController::HandleCaptureCompletion()" ) )
  8541   PRINT( _L( "Camera => CCamAppController::HandleCaptureCompletion()" ) )
  8548 
  8542 
  8549   if ( iInfo.iOperation != ECamFocused && iInfo.iOperation != ECamFocusing )
  8543   SetOperation( ECamNoOperation );
  8550       {
       
  8551       SetOperation( ECamNoOperation );
       
  8552       }
       
  8553   
  8544   
  8554   // Re-enable screensaver
  8545   // Re-enable screensaver
  8555   EnableScreenSaver( ETrue );
  8546   EnableScreenSaver( ETrue );
  8556 
  8547 
  8557   // If mmc dismount notification came while saving, allow the dismount now
  8548   // If mmc dismount notification came while saving, allow the dismount now
  8804 //
  8795 //
  8805 void CCamAppController::StartLocationTrailL()
  8796 void CCamAppController::StartLocationTrailL()
  8806   {
  8797   {
  8807   PRINT( _L("Camera => CCamAppController::StartLocationTrailL") );
  8798   PRINT( _L("Camera => CCamAppController::StartLocationTrailL") );
  8808   CCamAppUi* appUI = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
  8799   CCamAppUi* appUI = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
  8809 
       
  8810   if( !iRepository )
       
  8811     {
       
  8812     iRepository = CRepository::NewL( KCRUidCameraappSettings ); 
       
  8813     }
       
  8814 
       
  8815     TInt ftuValue=-1;
       
  8816     TInt retErr=0;
       
  8817     retErr = iRepository->Get( KCamCrFtuMessageFlag, ftuValue );
       
  8818 	if( ftuValue == 0 )
       
  8819 		{
       
  8820 		return;
       
  8821 		}
       
  8822 
       
  8823 	if( iRepository )
       
  8824 		{
       
  8825 		delete  iRepository;
       
  8826 		iRepository = NULL;
       
  8827 		}
       
  8828 
       
  8829 
  8800 
  8830   // If a stop request is pending but the trail is being restarted, stop 
  8801   // If a stop request is pending but the trail is being restarted, stop 
  8831   // and delete the timer
  8802   // and delete the timer
  8832   if( iLocationTrailTimer )
  8803   if( iLocationTrailTimer )
  8833   	{
  8804   	{
 10599   {
 10570   {
 10600   return ( iImageSaveActive->Count() > 0 );
 10571   return ( iImageSaveActive->Count() > 0 );
 10601   }
 10572   }
 10602 
 10573 
 10603 // ---------------------------------------------------------------------------
 10574 // ---------------------------------------------------------------------------
       
 10575 // IsRotationActive
       
 10576 // ---------------------------------------------------------------------------
       
 10577 //
       
 10578 TBool CCamAppController::IsRotationActive() const
       
 10579   {
       
 10580   PRINT( _L("Camera => CCamAppController::IsRotationActive" ));  
       
 10581   TBool rotationactive=iSnapShotRotator->IsActive();
       
 10582   if( !rotationactive && iRotatorAo )
       
 10583       {
       
 10584       rotationactive=iRotatorAo->IsActive();
       
 10585       }
       
 10586   PRINT1( _L("Camera <= CCamAppController::IsRotationActive rotationactive=%d" ), rotationactive );  
       
 10587   return rotationactive;
       
 10588   }
       
 10589 
       
 10590 // ---------------------------------------------------------------------------
 10604 // CapturedImages
 10591 // CapturedImages
 10605 // ---------------------------------------------------------------------------
 10592 // ---------------------------------------------------------------------------
 10606 //
 10593 //
 10607  TInt CCamAppController::CapturedImages() const
 10594  TInt CCamAppController::CapturedImages() const
 10608   {
 10595   {
 10611         
 10598         
 10612 // -----------------------------------------------------------------------------
 10599 // -----------------------------------------------------------------------------
 10613 //
 10600 //
 10614 // -----------------------------------------------------------------------------
 10601 // -----------------------------------------------------------------------------
 10615 //
 10602 //
 10616 void CCamAppController::SetSettingsPlugin( TUid aPlugin )
 10603 void CCamAppController::SetSettingsPlugin( CCamGSInterface* aPlugin )
 10617 	{
 10604 	{
 10618 	iPlugin = aPlugin;
 10605 	iPlugin = aPlugin;
 10619 	}
 10606 	}
 10620 
 10607 
 10621 // ---------------------------------------------------------------------------
 10608 // ---------------------------------------------------------------------------
 10939               SwitchToStandbyL( KErrNone );
 10926               SwitchToStandbyL( KErrNone );
 10940               }
 10927               }
 10941           else if( aType == EDriveDismount &&
 10928           else if( aType == EDriveDismount &&
 10942                   appUi->IsRecoverableStatus() )
 10929                   appUi->IsRecoverableStatus() )
 10943               {
 10930               {
       
 10931               TInt mmcInserted = 0;
 10944               TInt usbPersonality = 0;
 10932               TInt usbPersonality = 0;
       
 10933               User::LeaveIfError( RProperty::Get( KPSUidUikon, KUikMMCInserted, mmcInserted ) );
 10945               User::LeaveIfError(RProperty::Get(KPSUidUsbWatcher, 
 10934               User::LeaveIfError(RProperty::Get(KPSUidUsbWatcher, 
 10946                                             KUsbWatcherSelectedPersonality,
 10935                                             KUsbWatcherSelectedPersonality,
 10947                                             usbPersonality) );
 10936                                             usbPersonality) );
 10948               if( !IsMemoryAvailable(ECamMediaStorageMassStorage) &&
 10937               if( !IsMemoryAvailable(ECamMediaStorageMassStorage) &&
 10949                    !IsMemoryAvailable(ECamMediaStorageCard) )
 10938                    !IsMemoryAvailable(ECamMediaStorageCard) )
 10950                   {
 10939                   {
 10951                   if( KUsbPersonalityIdMS == usbPersonality )
 10940                   if( KUsbPersonalityIdMS == usbPersonality )
 10952                       {
 10941                       {
 10953                       SwitchToStandbyL( ECamErrMassStorageMode );
 10942                       SwitchToStandbyL( ECamErrMassStorageMode );
 10954                       }
 10943                       }
 10955                   else if ( aType == EDriveDismount )
 10944                   else if ( !mmcInserted )
 10956                       {
 10945                       {
 10957                       SwitchToStandbyL( ECamErrMemoryCardNotInserted );
 10946                       SwitchToStandbyL( ECamErrMemoryCardNotInserted );
 10958                       }
 10947                       }
 10959                   }
 10948                   }
 10960               }
 10949               }
 11251         {
 11240         {
 11252         iRotationArray->Reset();
 11241         iRotationArray->Reset();
 11253         }
 11242         }
 11254     if( BurstCaptureArray()->Snapshot( iCurrentImageIndex ) ) 
 11243     if( BurstCaptureArray()->Snapshot( iCurrentImageIndex ) ) 
 11255         {
 11244         {
 11256     // copy snapshot to preserve the original snapshot bitmap
 11245         // copy snapshot to preserve the original snapshot bitmap
 11257     // first get the handle for the original snapshot bitmap
 11246         // first get the handle for the original snapshot bitmap
 11258     CFbsBitmap* snapshot = new (ELeave)CFbsBitmap();
 11247         CFbsBitmap* snapshot = new (ELeave)CFbsBitmap();
 11259     CleanupStack::PushL( snapshot );
 11248         CleanupStack::PushL( snapshot );
 11260     snapshot->Duplicate( BurstCaptureArray()->Snapshot( iCurrentImageIndex )->Handle() );
 11249         snapshot->Duplicate( BurstCaptureArray()->Snapshot( iCurrentImageIndex )->Handle() );
 11261     //create a new bitmap with the same dimensions as the original snapshot
 11250         //create a new bitmap with the same dimensions as the original snapshot
 11262     iRotatedSnapshot = new (ELeave)CFbsBitmap();
 11251         iRotatedSnapshot = new (ELeave)CFbsBitmap();
 11263     iRotatedSnapshot->Create( snapshot->SizeInPixels(), snapshot->DisplayMode() );
 11252         iRotatedSnapshot->Create( snapshot->SizeInPixels(), snapshot->DisplayMode() );
 11264     TRect tmpRect( TPoint( 0, 0 ), snapshot->SizeInPixels() );
 11253         TRect tmpRect( TPoint( 0, 0 ), snapshot->SizeInPixels() );
 11265     TInt tmpLen = tmpRect.Width() * tmpRect.Height() * 4;
 11254         TInt tmpLen = tmpRect.Width() * tmpRect.Height() * 4;
 11266     //copy the snapshot data
 11255         //copy the snapshot data
 11267     iRotatedSnapshot->BeginDataAccess();
 11256         iRotatedSnapshot->BeginDataAccess();
 11268     snapshot->BeginDataAccess();
 11257         snapshot->BeginDataAccess();
 11269     Mem::Copy( iRotatedSnapshot->DataAddress(), snapshot->DataAddress(), tmpLen );
 11258         Mem::Copy( iRotatedSnapshot->DataAddress(), snapshot->DataAddress(), tmpLen );
 11270     iRotatedSnapshot->EndDataAccess();
 11259         iRotatedSnapshot->EndDataAccess();
 11271     snapshot->EndDataAccess();
 11260         snapshot->EndDataAccess();
 11272     // copy the filename 
 11261         // copy the filename 
 11273     iRotationArray->SetNextNameL( BurstCaptureArray()->FileName( iCurrentImageIndex ), BurstCaptureArray()->ImageName( iCurrentImageIndex ));
 11262         iRotationArray->SetNextNameL( BurstCaptureArray()->FileName( iCurrentImageIndex ), BurstCaptureArray()->ImageName( iCurrentImageIndex ));
 11274     // rotate the copied snapshot 
 11263         // rotate the copied snapshot 
 11275     if ( !iRotatorAo )
 11264         if ( !iRotatorAo )
 11276         {
 11265             {
 11277         iRotatorAo = CCamSyncRotatorAo::NewL( *this );
 11266             iRotatorAo = CCamSyncRotatorAo::NewL( *this );
 11278         }    
 11267             }    
 11279     iRotatorAo->RotateL( iRotatedSnapshot, MapCamOrientation2RotationAngle( iCaptureOrientation ) );
 11268         iRotatorAo->RotateL( iRotatedSnapshot, MapCamOrientation2RotationAngle( iCaptureOrientation ) );
 11280         
 11269             
 11281     CleanupStack::PopAndDestroy(snapshot);
 11270         CleanupStack::PopAndDestroy(snapshot);
 11282         } 
 11271         } 
 11283     PRINT( _L( "Camera <= CCamAppController::RotateSnapshotL" ) );    
 11272     PRINT( _L( "Camera <= CCamAppController::RotateSnapshotL" ) );    
 11284     } 
 11273     } 
 11285     
 11274     
 11286 // ---------------------------------------------------------------------------
 11275 // ---------------------------------------------------------------------------