camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp
changeset 43 0e652f8f1fbd
parent 28 3075d9b614e6
child 45 24fd82631616
--- a/camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp	Thu May 13 21:30:19 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.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"
@@ -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,15 +38,22 @@
 #include "cxeerror.h"
 #include "cxecenrepkeys.h"
 
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "cxesettingscenrepstoreTraces.h"
+#endif
+
+
 using namespace CxeSettingIds;
 
 
-/*
+/*!
 * CxeSettingsCenRepStore::CxeSettingsCenRepStore
 */
 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();
@@ -51,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();
 }
 
@@ -74,8 +84,10 @@
 }
 
 
-/*
+/*!
 * Generates XQSettingsKey from given setting/runtime key
+* \param key Name of the setting from which to generate the XQSettingsKey
+* \param[out] error Error code. CxeError::None if everything went fine.
 */
 XQSettingsKey
 CxeSettingsCenRepStore::generateXQSettingsKey(const QString& key, CxeError::Id& error)
@@ -103,7 +115,7 @@
 
 
 
-/*
+/*!
 * 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.
 * returns: QHash container, "contains" values associated with each key that are read from cenrep
@@ -112,6 +124,7 @@
 QHash<QString, QVariantList> CxeSettingsCenRepStore::loadRuntimeSettings(QList<QString>& runtimeKeys)
 {
     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;
@@ -145,12 +158,13 @@
 
     CX_DEBUG_EXIT_FUNCTION();
 
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_LOADRUNTIME_2, "msg: e_CX_SETTINGSSTORE_LOAD_RUNTIME 0");
     return settings;
 }
 
 
 
-/*
+/*!
 * Reads a value from cenrep
 * @param key   - setting key
 * @param value - setting value read from cenrep
@@ -183,15 +197,16 @@
 
 
 
-/*
-* Reads a value from cenrep
+/*!
+* Reads a value from cenrep and starts the value change monitoring.
 * @param key   - setting key
 * @param uid   - setting UID of the component that owns the setting key
-* @param type  - the type of key cr key or P&S key (constantly monitoring value)
+* @param type  - the type of key cr key or P&S key
 * @param value - setting value read from cenrep
+*
+* @sa handleValueChanged()
 */
-
-void CxeSettingsCenRepStore::get(long int uid,
+void CxeSettingsCenRepStore::startMonitoring(long int uid,
                                  unsigned long int key,
                                  Cxe::SettingKeyType type,
                                  QVariant &value)
@@ -208,21 +223,27 @@
     }
 
 	XQSettingsKey settingsKey(keyType, uid, key);
-    CX_DEBUG(("reading values from XQSettingsManager.."));
+    CX_DEBUG(("reading value from XQSettingsManager.."));
     value = mSettingsManager->readItemValue(settingsKey);
 
-    if (keyType == XQSettingsKey::TargetPublishAndSubscribe) {
-        bool ok = false;
-        ok = mSettingsManager->startMonitoring(settingsKey);
-        CX_DEBUG_ASSERT(ok);
+    // start monitoring changes for the key
+    // both P&S and Repository keys are monitored
+    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();
 }
 
 
 
-/*
+/*!
 * Sets a new value to cenrep
 * @param key   - setting key
 * @param newValue - new value set to the key in cenrep
@@ -258,7 +279,7 @@
 
 
 
-/*
+/*!
 * resets the cenrep store
 */
 void CxeSettingsCenRepStore::reset()
@@ -270,12 +291,14 @@
 }
 
 
-/*
-* adds key mapping to all settings
+/*!
+* Maps CxeSettingIds to cenrep key ids that XQSettingsManager understands
 */
 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
@@ -315,6 +338,38 @@
                   AudioMuteCr,
                   XQSettingsManager::TypeInt);
 
+    addKeyMapping(CxeSettingIds::GEOTAGGING,
+                  GeoTaggingCr,
+                  XQSettingsManager::TypeInt);
+
+    addKeyMapping(CxeSettingIds::FACE_TRACKING,
+                  FacetrackingCr,
+                  XQSettingsManager::TypeInt);
+
+    addKeyMapping(CxeSettingIds::IMAGE_SCENE,
+                  SceneModeStillCr,
+                  XQSettingsManager::TypeString);
+
+    addKeyMapping(CxeSettingIds::VIDEO_SCENE,
+                  SceneModeVideoCr,
+                  XQSettingsManager::TypeString);
+
+    addKeyMapping(CxeSettingIds::FLASH_MODE,
+                  FlashModeStillCr,
+                  XQSettingsManager::TypeInt);
+
+    addKeyMapping(CxeSettingIds::CAPTURE_SOUND_ALWAYS_ON,
+                  CaptureSoundAlwaysOnCr,
+                  XQSettingsManager::TypeInt);
+
+    addKeyMapping(CxeSettingIds::CAMERA_MODE,
+                  CameraModeCr,
+                  XQSettingsManager::TypeInt);
+
+    addKeyMapping(CxeSettingIds::GEOTAGGING_DISCLAIMER,
+                  GeoTaggingDisclaimerCr,
+                  XQSettingsManager::TypeInt);
+
     // mapping run-time keys
     addKeyMapping(CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS,
                   PrimaryCameraCaptureKeysCr,
@@ -346,11 +401,12 @@
                   XQSettingsManager::TypeString,
                   true);
 
+    OstTrace0(camerax_performance, CXESETTINGSCENREPSTORE_MAPKEYS_2, "msg: e_CX_SETTINGSSTORE_INIT_MAPPING 0");
 	CX_DEBUG_EXIT_FUNCTION();
 }
 
-/*
-* helper class to construct key mappings for each setting key
+/*!
+* helper method to construct key mappings for each setting key
 */
 void CxeSettingsCenRepStore::addKeyMapping(QString key,
                                            unsigned long int keyid,
@@ -381,14 +437,14 @@
 
 
 /*!
-*  Slot that handles value changed signal for Publish & Subscribe  key.
+*  Handles value changed signal from the XQSettingsManager.
+*  Emits signals corresponding the changed setting.
+*  \sa warningTonesChanged(), settingValueChanged()
 */
 void CxeSettingsCenRepStore::handleValueChanged(XQSettingsKey key, QVariant value)
 {
     CX_DEBUG_ENTER_FUNCTION();
-
     emit settingValueChanged(key.uid(), key.key(), value);
-
     CX_DEBUG_EXIT_FUNCTION();
 }