camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp
changeset 48 42ba2d16bf40
parent 37 64817133cd1d
--- a/camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp	Tue Jul 06 14:04:02 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp	Wed Aug 18 09:37:18 2010 +0300
@@ -25,6 +25,9 @@
 #include <QString>
 #include <QStringList>
 #include <QVariant>
+#ifdef Q_OS_SYMBIAN
+#include <ProfileEngineSDKCRKeys.h>
+#endif
 
 #include "xqsettingsmanager.h" // Settings Manager API
 #include "xqsettingskey.h"
@@ -35,10 +38,11 @@
 #include "cxeerror.h"
 #include "cxecenrepkeys.h"
 
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cxesettingscenrepstoreTraces.h"
+#endif
 
-#ifdef Q_OS_SYMBIAN
-#include <ProfileEngineSDKCRKeys.h>
-#endif
 
 using namespace CxeSettingIds;
 
@@ -49,6 +53,7 @@
 CxeSettingsCenRepStore::CxeSettingsCenRepStore()
 {
     CX_DEBUG_ENTER_FUNCTION();
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_1, "msg: e_CX_SETTINGSSTORE_CREATE 1");
 
     // map keys of type "string" to cenrep ids
     mapKeys();
@@ -56,13 +61,13 @@
 	// we create settings handle, scope user::scope
     mSettingsManager = new XQSettingsManager(this);
 
-    bool ok = false;
-    ok = connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
-                 this, SLOT(handleValueChanged(XQSettingsKey, QVariant)));
-    CX_DEBUG_ASSERT(ok);
+    bool ok = connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
+                      this, SLOT(handleValueChanged(XQSettingsKey, QVariant)));
+    CX_ASSERT_ALWAYS(ok);
 
     CX_DEBUG(("CxeSettingsCenRepStore - mSettingsManager ptr = %d", mSettingsManager));
 
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_2, "msg: e_CX_SETTINGSSTORE_CREATE 0");
 	CX_DEBUG_EXIT_FUNCTION();
 }
 
@@ -81,7 +86,7 @@
 
 /*!
 * Generates XQSettingsKey from given setting/runtime key
-* \param key Name of the setting from which to generate the XQSettingsKey 
+* \param key Name of the setting from which to generate the XQSettingsKey
 * \param[out] error Error code. CxeError::None if everything went fine.
 */
 XQSettingsKey
@@ -111,22 +116,23 @@
 
 
 /*!
-* Reads/loads all run-time settings values from cenrep
-* @param QList<QString> contains list of all runtime key ids which we use to load values from cenrep.
+* Reads/loads all run-time variation settings values from cenrep
+* @param QList<QString> contains list of all variation key ids which we use to load values from cenrep.
 * returns: QHash container, "contains" values associated with each key that are read from cenrep
-* NOTE: loading runtime settings should be done only ONCE at start-up.
+* NOTE: loading variation settings should be done only ONCE at start-up.
 */
-QHash<QString, QVariantList> CxeSettingsCenRepStore::loadRuntimeSettings(QList<QString>& runtimeKeys)
+QHash<QString, QVariantList> CxeSettingsCenRepStore::loadVariationSettings(QList<QString>& variationKeys)
 {
     CX_DEBUG_ENTER_FUNCTION();
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_LOADRUNTIME_1, "msg: e_CX_SETTINGSSTORE_LOAD_RUNTIME 1");
 
     QHash<QString, QVariantList> settings;
 	CxeError::Id err = CxeError::None;
 	QVariantList list;
 	QVariant data;
 
-    // parsing through the list of run-time keys and reading values from cenrep.
-    foreach (QString key, runtimeKeys) {
+    // parsing through the list of run-time variation keys and reading values from cenrep.
+    foreach (QString key, variationKeys) {
 
         // read the data from cenrep
         err = get(key, data);
@@ -152,6 +158,7 @@
 
     CX_DEBUG_EXIT_FUNCTION();
 
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_LOADRUNTIME_2, "msg: e_CX_SETTINGSSTORE_LOAD_RUNTIME 0");
     return settings;
 }
 
@@ -216,14 +223,20 @@
     }
 
 	XQSettingsKey settingsKey(keyType, uid, key);
-    CX_DEBUG(("reading values from XQSettingsManager.."));
+    CX_DEBUG(("reading value from XQSettingsManager.."));
     value = mSettingsManager->readItemValue(settingsKey);
 
     // start monitoring changes for the key
     // both P&S and Repository keys are monitored
-    bool ok = false;
-    ok = mSettingsManager->startMonitoring(settingsKey);
-    CX_DEBUG_ASSERT(ok);
+    bool ok = mSettingsManager->startMonitoring(settingsKey);
+    if (!ok) {
+        XQSettingsManager::Error error = mSettingsManager->error();
+        CX_DEBUG(("CxeSettingsCenRepStore - got error %d trying to start listening", error));
+        // If we try to start listening one key more than once,
+        // we get this error. We can safely ignore it.
+        ok = (XQSettingsManager::AlreadyExistsError == error);
+    }
+    CX_ASSERT_ALWAYS(ok);
 
     CX_DEBUG_EXIT_FUNCTION();
 }
@@ -284,6 +297,8 @@
 void CxeSettingsCenRepStore::mapKeys()
 {
     CX_DEBUG_ENTER_FUNCTION();
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_MAPKEYS_1, "msg: e_CX_SETTINGSSTORE_INIT_MAPPING 1");
+
     mKeyMapping.clear();
 
     // mapping setting keys
@@ -322,7 +337,7 @@
     addKeyMapping(CxeSettingIds::VIDEO_MUTE_SETTING,
                   AudioMuteCr,
                   XQSettingsManager::TypeInt);
-    
+
     addKeyMapping(CxeSettingIds::GEOTAGGING,
                   GeoTaggingCr,
                   XQSettingsManager::TypeInt);
@@ -346,7 +361,7 @@
     addKeyMapping(CxeSettingIds::CAPTURE_SOUND_ALWAYS_ON,
                   CaptureSoundAlwaysOnCr,
                   XQSettingsManager::TypeInt);
-				  
+
     addKeyMapping(CxeSettingIds::CAMERA_MODE,
                   CameraModeCr,
                   XQSettingsManager::TypeInt);
@@ -355,37 +370,23 @@
                   GeoTaggingDisclaimerCr,
                   XQSettingsManager::TypeInt);
 
-    // mapping run-time keys
-    addKeyMapping(CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS,
-                  PrimaryCameraCaptureKeysCr,
-                  XQSettingsManager::TypeString,
-                  true);
-
-    addKeyMapping(CxeRuntimeKeys::PRIMARY_CAMERA_AUTOFOCUS_KEYS,
-                  PrimaryCameraAutofocusKeysCr,
-                  XQSettingsManager::TypeString,
-                  true);
-
-    addKeyMapping(CxeRuntimeKeys::SECONDARY_CAMERA_CAPTURE_KEYS,
-                  SecondaryCameraCaptureKeysCr,
-                  XQSettingsManager::TypeString,
-                  true);
-
-    addKeyMapping(CxeRuntimeKeys::FREE_MEMORY_LEVELS,
+    // mapping run-time variation keys
+    addKeyMapping(CxeVariationKeys::FREE_MEMORY_LEVELS,
                   FreeMemoryLevelsCr,
                   XQSettingsManager::TypeString,
                   true);
 
-    addKeyMapping(CxeRuntimeKeys::STILL_MAX_ZOOM_LIMITS,
+    addKeyMapping(CxeVariationKeys::STILL_MAX_ZOOM_LIMITS,
                   StillMaxZoomLimitsCr,
                   XQSettingsManager::TypeString,
                   true);
 
-    addKeyMapping(CxeRuntimeKeys::VIDEO_MAX_ZOOM_LIMITS,
+    addKeyMapping(CxeVariationKeys::VIDEO_MAX_ZOOM_LIMITS,
                   VideoMaxZoomLimitsCr,
                   XQSettingsManager::TypeString,
                   true);
 
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_MAPKEYS_2, "msg: e_CX_SETTINGSSTORE_INIT_MAPPING 0");
 	CX_DEBUG_EXIT_FUNCTION();
 }