camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp
changeset 43 0e652f8f1fbd
parent 28 3075d9b614e6
child 45 24fd82631616
--- a/camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp	Thu May 13 21:30:19 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp	Thu Jul 15 01:55:05 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -23,6 +23,7 @@
 #include "cxevideocapturecontrolsymbian.h"
 #include "cxesettingscontrolsymbian.h"
 #include "cxeviewfindercontrolsymbian.h"
+#include "cxesnapshotcontrol.h"
 #include "cxefilenamegeneratorsymbian.h"
 #include "cxeautofocuscontrolsymbian.h"
 #include "cxezoomcontrolsymbian.h"
@@ -38,6 +39,7 @@
 #include "cxecameradevice.h"
 #include "cxememorymonitor.h"
 #include "cxediskmonitor.h"
+#include "cxegeotaggingtrail.h"
 
 #include "OstTraceDefinitions.h"
 #ifdef OST_TRACE_COMPILER_IN_USE
@@ -51,6 +53,7 @@
     : mCameraDeviceControl(NULL),
       mCameraDevice(NULL),
       mViewfinderControl(NULL),
+      mSnapshotControl(NULL),
       mStillCaptureControl(NULL),
       mVideoCaptureControl(NULL),
       mSettingsControl(NULL),
@@ -62,27 +65,12 @@
       mFilenameGenerator(NULL),
       mSensorEventHandler(NULL),
       mQualityPresets(NULL),
-      mFileSaveThread(NULL)
+      mFileSaveThread(NULL),
+      mDiskMonitor(NULL),
+      mMemoryMonitor(NULL),
+      mGeoTaggingTrail(NULL)
 {
-    CX_DEBUG_ENTER_FUNCTION();
-
-    // Do secondary construction during reserve call.
-    //! @todo temporarily commented as part of a hack to change the startup sequence
-    // to avoid GOOM issues
-   // connect(this, SIGNAL(reserveStarted()), this, SLOT(construct()));
-
-    CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian();
-    mCameraDeviceControl = deviceControl;
-    mCameraDevice = deviceControl->cameraDevice();
-    CX_ASSERT_ALWAYS(mCameraDeviceControl);
-    CX_ASSERT_ALWAYS(mCameraDevice);
-
-    mCameraDeviceControl->init();
-    //! @todo calling construct here is a hack to change the startup sequence
-    // to avoid GOOM issues
-    construct();
-    
-    CX_DEBUG_EXIT_FUNCTION();
+    CX_DEBUG_IN_FUNCTION();
 }
 
 
@@ -110,7 +98,16 @@
 
     // Check we do this only once.
     if (!mSettingsModel) {
-        OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "e_CX_ENGINE_CREATE_CONTROLS 1");
+        OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "msg: e_CX_ENGINE_CREATE_CONTROLS 1");
+
+        CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian();
+        mCameraDeviceControl = deviceControl;
+        mCameraDevice = deviceControl->cameraDevice();
+
+        CX_ASSERT_ALWAYS(mCameraDeviceControl);
+        CX_ASSERT_ALWAYS(mCameraDevice);
+
+        mCameraDeviceControl->init();
 
         CxeSettingsCenRepStore *settingsStore(NULL);
         if (XQServiceUtil::isService()) {
@@ -124,11 +121,22 @@
         CX_DEBUG_ASSERT(mSettingsModel);
 
         mSettings = new CxeSettingsImp(*mSettingsModel);
-        
+
+        // Loading current camera mode value from settings store and updating
+		// devicecontrol
+        Cxe::CameraMode cameraMode = Cxe::ImageMode;
+        int value;
+        CxeError::Id err = mSettings->get(CxeSettingIds::CAMERA_MODE, value);
+        if (!err) {
+            cameraMode = static_cast<Cxe::CameraMode>(value);
+        }
+        // set current camera mode to devicecontrol.
+        mCameraDeviceControl->setMode(cameraMode);
+
         //! @todo a temporary hack to change the startup sequence to avoid GOOM problems
         static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode());
-        
-        
+
+
         // Connect P&S key updates to settings signal.
         connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)),
                 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)));
@@ -153,25 +161,32 @@
         mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice,
             *mCameraDeviceControl);
 
-        mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice);
+        mSnapshotControl = new CxeSnapshotControl(*mCameraDevice);
+
+        mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice,
+		                            *mSettings);
 
         mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread();
 
         mStillCaptureControl = new CxeStillCaptureControlSymbian(
-            *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl,
+            *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl,
             *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl,
             *mSettings, *mQualityPresets, *mFileSaveThread, *mDiskMonitor);
 
-        mZoomControl = new CxeZoomControlSymbian( *mCameraDevice,
-            *mCameraDeviceControl, *mSettings, *mFeatureManager);
+        mZoomControl = new CxeZoomControlSymbian(
+            *mCameraDevice, *mCameraDeviceControl, *mSettings, *mFeatureManager);
 
         mVideoCaptureControl = new CxeVideoCaptureControlSymbian(
-            *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl,
+            *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl,
             *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor);
 
         mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings);
 
-        OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "e_CX_ENGINE_CREATE_CONTROLS 0");
+        mGeoTaggingTrail = new CxeGeoTaggingTrail(*mStillCaptureControl,
+                                                  *mVideoCaptureControl,
+                                                  *mSettings);
+
+        OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "msg: e_CX_ENGINE_CREATE_CONTROLS 0");
     }
 
     CX_DEBUG_EXIT_FUNCTION();
@@ -183,7 +198,7 @@
 void CxeEngineSymbian::connectSignals()
 {
     CX_DEBUG_ENTER_FUNCTION();
-    OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "e_CX_ENGINE_CONNECT_SIGNALS 1");
+    OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "msg: e_CX_ENGINE_CONNECT_SIGNALS 1");
 
     // enabling scene setting change callbacks to Autofocus control
     connect(mSettings,
@@ -200,7 +215,7 @@
     // Connect signals for ECam events
     connect(mCameraDeviceControl,
             SIGNAL(cameraEvent(int,int)),
-            mVideoCaptureControl,
+            mSnapshotControl,
             SLOT(handleCameraEvent(int,int)));
 
     connect(mCameraDeviceControl,
@@ -208,6 +223,11 @@
             mAutoFocusControl,
             SLOT(handleCameraEvent(int,int)));
 
+    connect(mCameraDeviceControl,
+            SIGNAL(cameraEvent(int,int)),
+            mStillCaptureControl,
+            SLOT(handleCameraEvent(int,int)));
+
     // Connect signal for device ready events
     connect(mCameraDeviceControl,
             SIGNAL(deviceReady()),
@@ -240,19 +260,27 @@
     // Connect file saving thread to snapshot signals and video saved signal.
     // Image saving it handles internally.
     connect(mStillCaptureControl,
-            SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, int)),
+            SIGNAL(snapshotReady(CxeError::Id, const QImage&, int)),
             mFileSaveThread,
-            SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, int)));
+            SLOT(handleSnapshotReady(CxeError::Id, const QImage&, int)));
     connect(mVideoCaptureControl,
             SIGNAL(videoComposed(CxeError::Id, const QString&)),
             mFileSaveThread,
             SLOT(handleVideoSaved(CxeError::Id, const QString&)));
     connect(mVideoCaptureControl,
-            SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
+            SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)),
             mFileSaveThread,
-            SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&)));
+            SLOT(handleSnapshotReady(CxeError::Id, const QImage&, const QString&)));
+
 
-    OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0");
+    // stop location trail when releasing camera.
+    connect(mCameraDevice,
+            SIGNAL(prepareForRelease()),
+            mGeoTaggingTrail,
+            SLOT(stop()),
+            Qt::UniqueConnection);
+
+    OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0");
 
     CX_DEBUG_EXIT_FUNCTION();
 }
@@ -261,11 +289,16 @@
 {
     CX_DEBUG_ENTER_FUNCTION();
 
+    // Saving current camera mode to cenrep
+    saveMode();
+
+    delete mGeoTaggingTrail;
     delete mAutoFocusControl;
     delete mZoomControl;
     delete mSettingsControl;
     delete mStillCaptureControl;
     delete mVideoCaptureControl;
+    delete mSnapshotControl;
     delete mViewfinderControl;
     delete mFilenameGenerator;
     delete mDiskMonitor;
@@ -290,6 +323,11 @@
     return *mViewfinderControl;
 }
 
+CxeSnapshotControl &CxeEngineSymbian::snapshotControl()
+{
+    return *mSnapshotControl;
+}
+
 CxeStillCaptureControl &CxeEngineSymbian::stillCaptureControl()
 {
     return *mStillCaptureControl;
@@ -310,13 +348,17 @@
     return *mZoomControl;
 }
 
-// Get the settings handle
+/*!
+Returns the settings handle
+*/
 CxeSettings &CxeEngineSymbian::settings()
 {
     return *mSettings;
 }
 
-// Get the sensor event  handle
+/*!
+Returns the sensor event  handle
+*/
 CxeSensorEventHandler &CxeEngineSymbian::sensorEventHandler()
 {
     return *mSensorEventHandler;
@@ -329,14 +371,23 @@
 }
 
 /*!
-* Get memory monitor utility handle.
+* Returns memory monitor utility handle.
 */
 CxeMemoryMonitor &CxeEngineSymbian::memoryMonitor()
 {
     return *mMemoryMonitor;
 }
 
-/*
+
+/*!
+ Returns geotaggingtrail handle
+ */
+CxeGeoTaggingTrail &CxeEngineSymbian::geoTaggingTrail()
+{
+    return *mGeoTaggingTrail;
+}
+
+/*!
 * Returns true, if the engine is ready or else false.
 */
 bool CxeEngineSymbian::isEngineReady()
@@ -364,7 +415,7 @@
 void CxeEngineSymbian::doInit()
 {
     CX_DEBUG_ENTER_FUNCTION();
-    OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "e_CX_ENGINE_DO_INIT 1");
+    OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "msg: e_CX_ENGINE_DO_INIT 1");
 
     mFilenameGenerator->init(mode());
     // load settings whenever we change mode or start camera or switch camera
@@ -373,26 +424,44 @@
         settingsImp->loadSettings(mode());
     }
 
-
     if (mode() == Cxe::ImageMode) {
+        // start geotagging trail in image mode.
+        startGeotaggingTrail();
         mVideoCaptureControl->deinit();
         mStillCaptureControl->init();
     } else if (mode() == Cxe::VideoMode) {
         mStillCaptureControl->deinit();
+        if (mGeoTaggingTrail) {
+            // in video mode, Geotagging is not supported for now.
+            mGeoTaggingTrail->stop();
+        }
         mVideoCaptureControl->init();
     }
 
-    OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0");
+    OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "msg: e_CX_ENGINE_DO_INIT 0");
 
     CX_DEBUG_EXIT_FUNCTION();
 }
 
+/*!
+ * Returns camera mode.
+ */
 Cxe::CameraMode CxeEngineSymbian::mode() const
 {
     return mCameraDeviceControl->mode();
 }
 
 /*!
+ * Sets the camera mode.
+ * \parama mode New camera mode
+ */
+void CxeEngineSymbian::setMode(Cxe::CameraMode mode)
+{
+    CX_DEBUG_ENTER_FUNCTION();
+    mCameraDeviceControl->setMode(mode);
+    CX_DEBUG_EXIT_FUNCTION();
+}
+/*!
     Check if we need to reserve camera.
 */
 bool CxeEngineSymbian::reserveNeeded()
@@ -457,6 +526,7 @@
 void CxeEngineSymbian::initMode(Cxe::CameraMode cameraMode)
 {
     CX_DEBUG_ENTER_FUNCTION();
+    OstTrace0(camerax_performance, CXEENGINE_INITMODE_IN, "msg: e_CX_ENGINE_INIT_MODE 1");
 
     if (mode() == cameraMode) {
         CX_DEBUG(("initMode() called for current mode"));
@@ -508,6 +578,7 @@
         }
     }
 
+    OstTrace0(camerax_performance, CXEENGINE_INITMODE_OUT, "msg: e_CX_ENGINE_INIT_MODE 0");
     CX_DEBUG_EXIT_FUNCTION();
 }
 
@@ -519,4 +590,44 @@
     CX_DEBUG_EXIT_FUNCTION();
 }
 
+
+/*!
+* Saves current mode to the cenrep
+*/
+void CxeEngineSymbian::saveMode()
+{
+    CX_DEBUG_ENTER_FUNCTION();
+
+    if (mCameraDeviceControl && mSettings) {
+        int value = mCameraDeviceControl->mode();
+        mSettings->set(CxeSettingIds::CAMERA_MODE, value);
+    }
+
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
+
+/*!
+* Start geotagging trail.
+*/
+void CxeEngineSymbian::startGeotaggingTrail()
+{
+    CX_DEBUG_ENTER_FUNCTION();
+    OstTrace0(camerax_performance, CXEENGINE_START_GEO_IN, "msg: e_CX_ENGINE_START_GEOTAGGING 1");
+
+    if (mGeoTaggingTrail && mSettings) {
+        // location trail is limited to image mode only for now.
+        int value = Cxe::GeoTaggingDisclaimerDisabled;
+        mSettings->get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value);
+
+        // we start location trail only when Geotagging First-time-use note is accepted by user.
+        if (value == Cxe::GeoTaggingDisclaimerDisabled) {
+            mGeoTaggingTrail->start();
+        }
+    }
+
+    OstTrace0(camerax_performance, CXEENGINE_START_GEO_OUT, "msg: e_CX_ENGINE_START_GEOTAGGING 0");
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
 // End of file