camerauis/cameraxui/cxengine/src/cxesettingscenrepstore.cpp
changeset 37 64817133cd1d
parent 32 5c1e3c6aa4ef
child 42 feebad15db8c
child 48 42ba2d16bf40
equal deleted inserted replaced
36:b12f3922a74f 37:64817133cd1d
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    33 #include "cxutils.h"
    33 #include "cxutils.h"
    34 #include "cxenamespace.h"
    34 #include "cxenamespace.h"
    35 #include "cxeerror.h"
    35 #include "cxeerror.h"
    36 #include "cxecenrepkeys.h"
    36 #include "cxecenrepkeys.h"
    37 
    37 
       
    38 
       
    39 #ifdef Q_OS_SYMBIAN
       
    40 #include <ProfileEngineSDKCRKeys.h>
       
    41 #endif
       
    42 
    38 using namespace CxeSettingIds;
    43 using namespace CxeSettingIds;
    39 
    44 
    40 
    45 
    41 /*
    46 /*!
    42 * CxeSettingsCenRepStore::CxeSettingsCenRepStore
    47 * CxeSettingsCenRepStore::CxeSettingsCenRepStore
    43 */
    48 */
    44 CxeSettingsCenRepStore::CxeSettingsCenRepStore()
    49 CxeSettingsCenRepStore::CxeSettingsCenRepStore()
    45 {
    50 {
    46     CX_DEBUG_ENTER_FUNCTION();
    51     CX_DEBUG_ENTER_FUNCTION();
    72     delete mSettingsManager;
    77     delete mSettingsManager;
    73     CX_DEBUG_EXIT_FUNCTION();
    78     CX_DEBUG_EXIT_FUNCTION();
    74 }
    79 }
    75 
    80 
    76 
    81 
    77 /*
    82 /*!
    78 * Generates XQSettingsKey from given setting/runtime key
    83 * Generates XQSettingsKey from given setting/runtime key
       
    84 * \param key Name of the setting from which to generate the XQSettingsKey 
       
    85 * \param[out] error Error code. CxeError::None if everything went fine.
    79 */
    86 */
    80 XQSettingsKey
    87 XQSettingsKey
    81 CxeSettingsCenRepStore::generateXQSettingsKey(const QString& key, CxeError::Id& error)
    88 CxeSettingsCenRepStore::generateXQSettingsKey(const QString& key, CxeError::Id& error)
    82 {
    89 {
    83     CX_DEBUG_ENTER_FUNCTION();
    90     CX_DEBUG_ENTER_FUNCTION();
   101 	return newKey;
   108 	return newKey;
   102 }
   109 }
   103 
   110 
   104 
   111 
   105 
   112 
   106 /*
   113 /*!
   107 * Reads/loads all run-time settings values from cenrep
   114 * Reads/loads all run-time settings values from cenrep
   108 * @param QList<QString> contains list of all runtime key ids which we use to load values from cenrep.
   115 * @param QList<QString> contains list of all runtime key ids which we use to load values from cenrep.
   109 * returns: QHash container, "contains" values associated with each key that are read from cenrep
   116 * returns: QHash container, "contains" values associated with each key that are read from cenrep
   110 * NOTE: loading runtime settings should be done only ONCE at start-up.
   117 * NOTE: loading runtime settings should be done only ONCE at start-up.
   111 */
   118 */
   148     return settings;
   155     return settings;
   149 }
   156 }
   150 
   157 
   151 
   158 
   152 
   159 
   153 /*
   160 /*!
   154 * Reads a value from cenrep
   161 * Reads a value from cenrep
   155 * @param key   - setting key
   162 * @param key   - setting key
   156 * @param value - setting value read from cenrep
   163 * @param value - setting value read from cenrep
   157 */
   164 */
   158 
   165 
   181     return err;
   188     return err;
   182 }
   189 }
   183 
   190 
   184 
   191 
   185 
   192 
   186 /*
   193 /*!
   187 * Reads a value from cenrep
   194 * Reads a value from cenrep and starts the value change monitoring.
   188 * @param key   - setting key
   195 * @param key   - setting key
   189 * @param uid   - setting UID of the component that owns the setting key
   196 * @param uid   - setting UID of the component that owns the setting key
   190 * @param type  - the type of key cr key or P&S key (constantly monitoring value)
   197 * @param type  - the type of key cr key or P&S key
   191 * @param value - setting value read from cenrep
   198 * @param value - setting value read from cenrep
   192 */
   199 *
   193 
   200 * @sa handleValueChanged()
   194 void CxeSettingsCenRepStore::get(long int uid,
   201 */
       
   202 void CxeSettingsCenRepStore::startMonitoring(long int uid,
   195                                  unsigned long int key,
   203                                  unsigned long int key,
   196                                  Cxe::SettingKeyType type,
   204                                  Cxe::SettingKeyType type,
   197                                  QVariant &value)
   205                                  QVariant &value)
   198 {
   206 {
   199     CX_DEBUG_ENTER_FUNCTION();
   207     CX_DEBUG_ENTER_FUNCTION();
   209 
   217 
   210 	XQSettingsKey settingsKey(keyType, uid, key);
   218 	XQSettingsKey settingsKey(keyType, uid, key);
   211     CX_DEBUG(("reading values from XQSettingsManager.."));
   219     CX_DEBUG(("reading values from XQSettingsManager.."));
   212     value = mSettingsManager->readItemValue(settingsKey);
   220     value = mSettingsManager->readItemValue(settingsKey);
   213 
   221 
   214     if (keyType == XQSettingsKey::TargetPublishAndSubscribe) {
   222     // start monitoring changes for the key
   215         bool ok = false;
   223     // both P&S and Repository keys are monitored
   216         ok = mSettingsManager->startMonitoring(settingsKey);
   224     bool ok = false;
   217         CX_DEBUG_ASSERT(ok);
   225     ok = mSettingsManager->startMonitoring(settingsKey);
   218     }
   226     CX_DEBUG_ASSERT(ok);
   219 
   227 
   220     CX_DEBUG_EXIT_FUNCTION();
   228     CX_DEBUG_EXIT_FUNCTION();
   221 }
   229 }
   222 
   230 
   223 
   231 
   224 
   232 
   225 /*
   233 /*!
   226 * Sets a new value to cenrep
   234 * Sets a new value to cenrep
   227 * @param key   - setting key
   235 * @param key   - setting key
   228 * @param newValue - new value set to the key in cenrep
   236 * @param newValue - new value set to the key in cenrep
   229 */
   237 */
   230 CxeError::Id CxeSettingsCenRepStore::set(const QString& key, const QVariant newValue)
   238 CxeError::Id CxeSettingsCenRepStore::set(const QString& key, const QVariant newValue)
   256     return err;
   264     return err;
   257 }
   265 }
   258 
   266 
   259 
   267 
   260 
   268 
   261 /*
   269 /*!
   262 * resets the cenrep store
   270 * resets the cenrep store
   263 */
   271 */
   264 void CxeSettingsCenRepStore::reset()
   272 void CxeSettingsCenRepStore::reset()
   265 {
   273 {
   266     CX_DEBUG_ENTER_FUNCTION();
   274     CX_DEBUG_ENTER_FUNCTION();
   268     //!@Todo: How to reset the repository.
   276     //!@Todo: How to reset the repository.
   269     CX_DEBUG_EXIT_FUNCTION();
   277     CX_DEBUG_EXIT_FUNCTION();
   270 }
   278 }
   271 
   279 
   272 
   280 
   273 /*
   281 /*!
   274 * adds key mapping to all settings
   282 * Maps CxeSettingIds to cenrep key ids that XQSettingsManager understands
   275 */
   283 */
   276 void CxeSettingsCenRepStore::mapKeys()
   284 void CxeSettingsCenRepStore::mapKeys()
   277 {
   285 {
   278     CX_DEBUG_ENTER_FUNCTION();
   286     CX_DEBUG_ENTER_FUNCTION();
   279     mKeyMapping.clear();
   287     mKeyMapping.clear();
   321 
   329 
   322     addKeyMapping(CxeSettingIds::FACE_TRACKING,
   330     addKeyMapping(CxeSettingIds::FACE_TRACKING,
   323                   FacetrackingCr,
   331                   FacetrackingCr,
   324                   XQSettingsManager::TypeInt);
   332                   XQSettingsManager::TypeInt);
   325 
   333 
       
   334     addKeyMapping(CxeSettingIds::IMAGE_SCENE,
       
   335                   SceneModeStillCr,
       
   336                   XQSettingsManager::TypeString);
       
   337 
       
   338     addKeyMapping(CxeSettingIds::VIDEO_SCENE,
       
   339                   SceneModeVideoCr,
       
   340                   XQSettingsManager::TypeString);
       
   341 
       
   342     addKeyMapping(CxeSettingIds::FLASH_MODE,
       
   343                   FlashModeStillCr,
       
   344                   XQSettingsManager::TypeInt);
       
   345 
   326     addKeyMapping(CxeSettingIds::CAPTURE_SOUND_ALWAYS_ON,
   346     addKeyMapping(CxeSettingIds::CAPTURE_SOUND_ALWAYS_ON,
   327                   CaptureSoundAlwaysOnCr,
   347                   CaptureSoundAlwaysOnCr,
       
   348                   XQSettingsManager::TypeInt);
       
   349 				  
       
   350     addKeyMapping(CxeSettingIds::CAMERA_MODE,
       
   351                   CameraModeCr,
       
   352                   XQSettingsManager::TypeInt);
       
   353 
       
   354     addKeyMapping(CxeSettingIds::GEOTAGGING_DISCLAIMER,
       
   355                   GeoTaggingDisclaimerCr,
   328                   XQSettingsManager::TypeInt);
   356                   XQSettingsManager::TypeInt);
   329 
   357 
   330     // mapping run-time keys
   358     // mapping run-time keys
   331     addKeyMapping(CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS,
   359     addKeyMapping(CxeRuntimeKeys::PRIMARY_CAMERA_CAPTURE_KEYS,
   332                   PrimaryCameraCaptureKeysCr,
   360                   PrimaryCameraCaptureKeysCr,
   359                   true);
   387                   true);
   360 
   388 
   361 	CX_DEBUG_EXIT_FUNCTION();
   389 	CX_DEBUG_EXIT_FUNCTION();
   362 }
   390 }
   363 
   391 
   364 /*
   392 /*!
   365 * helper class to construct key mappings for each setting key
   393 * helper method to construct key mappings for each setting key
   366 */
   394 */
   367 void CxeSettingsCenRepStore::addKeyMapping(QString key,
   395 void CxeSettingsCenRepStore::addKeyMapping(QString key,
   368                                            unsigned long int keyid,
   396                                            unsigned long int keyid,
   369                                            XQSettingsManager::Type type,
   397                                            XQSettingsManager::Type type,
   370                                            bool readOnly)
   398                                            bool readOnly)
   391 }
   419 }
   392 
   420 
   393 
   421 
   394 
   422 
   395 /*!
   423 /*!
   396 *  Slot that handles value changed signal for Publish & Subscribe  key.
   424 *  Handles value changed signal from the XQSettingsManager.
       
   425 *  Emits signals corresponding the changed setting.
       
   426 *  \sa warningTonesChanged(), settingValueChanged()
   397 */
   427 */
   398 void CxeSettingsCenRepStore::handleValueChanged(XQSettingsKey key, QVariant value)
   428 void CxeSettingsCenRepStore::handleValueChanged(XQSettingsKey key, QVariant value)
   399 {
   429 {
   400     CX_DEBUG_ENTER_FUNCTION();
   430     CX_DEBUG_ENTER_FUNCTION();
   401 
       
   402     emit settingValueChanged(key.uid(), key.key(), value);
   431     emit settingValueChanged(key.uid(), key.key(), value);
   403 
       
   404     CX_DEBUG_EXIT_FUNCTION();
   432     CX_DEBUG_EXIT_FUNCTION();
   405 }
   433 }
   406 
   434 
   407 const QHash<QString, CxeSettingsCenRepStore::CxeCenRepDefinition>& CxeSettingsCenRepStore::keyMapping() const
   435 const QHash<QString, CxeSettingsCenRepStore::CxeCenRepDefinition>& CxeSettingsCenRepStore::keyMapping() const
   408 {
   436 {