camerauis/cameraxui/cxengine/src/cxesettingsstoredesktop.cpp
author hgs
Wed, 18 Aug 2010 14:02:45 +0300
changeset 51 ccc0e7e3344f
parent 45 24fd82631616
permissions -rw-r--r--
201031_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description: Desktop specific settings handling
hgs
parents:
diff changeset
    15
* 
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <QVariant>
hgs
parents:
diff changeset
    19
#include <QList>
hgs
parents:
diff changeset
    20
#include <QMultiMap>
hgs
parents:
diff changeset
    21
#include <QMetaType>
hgs
parents:
diff changeset
    22
#include <QString>
hgs
parents:
diff changeset
    23
#include <QStringList>
hgs
parents:
diff changeset
    24
#include <QVariant>
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include "cxesettingsstoredesktop.h"
hgs
parents:
diff changeset
    27
#include "cxenamespace.h"
hgs
parents:
diff changeset
    28
#include "cxutils.h"
hgs
parents:
diff changeset
    29
#include "cxenamespace.h"
hgs
parents:
diff changeset
    30
#include "cxeerror.h"
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
using namespace Cxe;
hgs
parents:
diff changeset
    33
using namespace CxeSettingIds;
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
/*!
hgs
parents:
diff changeset
    37
* Constructor
hgs
parents:
diff changeset
    38
*/
hgs
parents:
diff changeset
    39
CxeSettingsStoreDesktop::CxeSettingsStoreDesktop()
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
    initSettings();
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
    46
}
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
/*!
hgs
parents:
diff changeset
    51
* Destructor
hgs
parents:
diff changeset
    52
*/
hgs
parents:
diff changeset
    53
CxeSettingsStoreDesktop::~CxeSettingsStoreDesktop()
hgs
parents:
diff changeset
    54
{
hgs
parents:
diff changeset
    55
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
    56
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
    57
}
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
/*!
hgs
parents:
diff changeset
    62
* Initalizes settings with default values.
hgs
parents:
diff changeset
    63
*/
hgs
parents:
diff changeset
    64
void CxeSettingsStoreDesktop::initSettings()
hgs
parents:
diff changeset
    65
{
hgs
parents:
diff changeset
    66
    mSettings[CAMERA_MODE] = QVariant(0);
hgs
parents:
diff changeset
    67
    mSettings[FLASH_MODE] = QVariant(0);
hgs
parents:
diff changeset
    68
    mSettings[WHITE_BALANCE] = QVariant(0);
hgs
parents:
diff changeset
    69
    mSettings[LIGHT_SENSITIVITY] = QVariant(0);
hgs
parents:
diff changeset
    70
    mSettings[EXPOSURE_MODE] = QVariant(0);
hgs
parents:
diff changeset
    71
    mSettings[SHARPNESS] = QVariant(0);
hgs
parents:
diff changeset
    72
    mSettings[COLOR_TONE] = QVariant(0);
hgs
parents:
diff changeset
    73
    mSettings[EV_COMPENSATION_VALUE] = QVariant(0);
hgs
parents:
diff changeset
    74
    mSettings[CONTRAST] = QVariant(0);
hgs
parents:
diff changeset
    75
    mSettings[BRIGHTNESS] = QVariant(0);
hgs
parents:
diff changeset
    76
    mSettings[SCENE_ID] = QVariant(IMAGE_SCENE_AUTO);
hgs
parents:
diff changeset
    77
    mSettings[IMAGE_QUALITY] = QVariant(0);
hgs
parents:
diff changeset
    78
    mSettings[VIDEO_QUALITY] = QVariant(0);
hgs
parents:
diff changeset
    79
    mSettings[SELF_TIMER] = QVariant(-1);
hgs
parents:
diff changeset
    80
    mSettings[FACE_TRACKING] = QVariant(0);
hgs
parents:
diff changeset
    81
    mSettings[GEOTAGGING] = QVariant(0);
hgs
parents:
diff changeset
    82
    mSettings[IMAGE_SCENE] = QVariant(IMAGE_SCENE_AUTO);
hgs
parents:
diff changeset
    83
    mSettings[VIDEO_SCENE] = QVariant(VIDEO_SCENE_AUTO);
hgs
parents:
diff changeset
    84
    mSettings[STILL_SHOWCAPTURED] = QVariant(2000);
hgs
parents:
diff changeset
    85
    mSettings[VIDEO_SHOWCAPTURED] = QVariant(2000);
hgs
parents:
diff changeset
    86
}
hgs
parents:
diff changeset
    87
hgs
parents:
diff changeset
    88
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
/*!
hgs
parents:
diff changeset
    91
* Reads all run-time settings values from the internal hash
hgs
parents:
diff changeset
    92
* \param QList<QString> contains list of all runtime key ids.
hgs
parents:
diff changeset
    93
* \return QHash containing value associated to the keys
hgs
parents:
diff changeset
    94
* \note loading runtime settings should be done only ONCE at start-up.
hgs
parents:
diff changeset
    95
*/
hgs
parents:
diff changeset
    96
QHash<QString, QVariantList> CxeSettingsStoreDesktop::loadVariationSettings(QList<QString>& runtimeKeys)
hgs
parents:
diff changeset
    97
{
hgs
parents:
diff changeset
    98
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
    QHash<QString, QVariantList> settings;
hgs
parents:
diff changeset
   101
    CxeError::Id err = CxeError::None;
hgs
parents:
diff changeset
   102
    QVariantList list;
hgs
parents:
diff changeset
   103
    QVariant data;
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
    // parsing through the list of run-time keys and reading values from the settings array.
hgs
parents:
diff changeset
   106
    foreach (QString key, runtimeKeys) {
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
        // read the data from cenrep
hgs
parents:
diff changeset
   109
        err = get(key, data);
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
        // clear the list
hgs
parents:
diff changeset
   112
        list.clear();
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
        if (CxeError::None == err) {
hgs
parents:
diff changeset
   115
            if (data.type() == QMetaType::QString ) {
hgs
parents:
diff changeset
   116
                QString str = data.toString();
hgs
parents:
diff changeset
   117
                QVariant strListVariant = qVariantFromValue(str.split(","));
hgs
parents:
diff changeset
   118
                //generate qvariantlist from strListVariant
hgs
parents:
diff changeset
   119
                list = strListVariant.toList();
hgs
parents:
diff changeset
   120
            } else {
hgs
parents:
diff changeset
   121
                // if its of any other type, then just append to the list
hgs
parents:
diff changeset
   122
                list.append(data);
hgs
parents:
diff changeset
   123
            }
hgs
parents:
diff changeset
   124
        }
hgs
parents:
diff changeset
   125
        // append the values associated with the key to the list.
hgs
parents:
diff changeset
   126
        settings.insert(key, list);
hgs
parents:
diff changeset
   127
hgs
parents:
diff changeset
   128
    } // end for
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
    return settings;
hgs
parents:
diff changeset
   133
}
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
hgs
parents:
diff changeset
   137
/*!
hgs
parents:
diff changeset
   138
* Reads a setting from the internal hash
hgs
parents:
diff changeset
   139
* \param "key"   - setting key
hgs
parents:
diff changeset
   140
* \param "value" - setting value read from cenrep
hgs
parents:
diff changeset
   141
* \return Error code
hgs
parents:
diff changeset
   142
*/
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
CxeError::Id CxeSettingsStoreDesktop::get(const QString& key, QVariant &value)
hgs
parents:
diff changeset
   145
{
hgs
parents:
diff changeset
   146
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
   147
hgs
parents:
diff changeset
   148
    CX_DEBUG(("CxeSettingsStoreDesktop::get - key: %s", key.toAscii().constData()));
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
    if (mSettings.contains(key) )
hgs
parents:
diff changeset
   151
    {
hgs
parents:
diff changeset
   152
        value.setValue(mSettings.value(key));
hgs
parents:
diff changeset
   153
    }
hgs
parents:
diff changeset
   154
hgs
parents:
diff changeset
   155
    CxeError::Id err = CxeError::None;
hgs
parents:
diff changeset
   156
hgs
parents:
diff changeset
   157
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
    return err;
hgs
parents:
diff changeset
   160
}
hgs
parents:
diff changeset
   161
hgs
parents:
diff changeset
   162
/*!
hgs
parents:
diff changeset
   163
* Reads a value from the settings store and starts monitoring it.
hgs
parents:
diff changeset
   164
* \param "uid"   - UID of the component that own setting key
hgs
parents:
diff changeset
   165
* \param "key"   - setting key id
hgs
parents:
diff changeset
   166
* \param "type"  - type of setting key
hgs
parents:
diff changeset
   167
* \param "value" - setting value read from cenrep
hgs
parents:
diff changeset
   168
* \note Not only dummy implementation in desktop.
hgs
parents:
diff changeset
   169
*/
hgs
parents:
diff changeset
   170
void CxeSettingsStoreDesktop::startMonitoring(long int uid, unsigned long int key, Cxe::SettingKeyType type, QVariant &value)
hgs
parents:
diff changeset
   171
{
hgs
parents:
diff changeset
   172
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
   173
    value = QVariant::Invalid;
hgs
parents:
diff changeset
   174
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
   175
}
hgs
parents:
diff changeset
   176
hgs
parents:
diff changeset
   177
/*!
hgs
parents:
diff changeset
   178
* Sets a new value to the internal hash
hgs
parents:
diff changeset
   179
* \param "key"   - setting key
hgs
parents:
diff changeset
   180
* \param "newValue" - new value set to the key in cenrep
hgs
parents:
diff changeset
   181
* \return Error code, in this case, always CxeError::None
hgs
parents:
diff changeset
   182
*/
hgs
parents:
diff changeset
   183
CxeError::Id CxeSettingsStoreDesktop::set(const QString& key, const QVariant newValue)
hgs
parents:
diff changeset
   184
{
hgs
parents:
diff changeset
   185
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
   186
hgs
parents:
diff changeset
   187
    if (mSettings.contains(key) )
hgs
parents:
diff changeset
   188
    {
hgs
parents:
diff changeset
   189
        mSettings[key] = newValue;
hgs
parents:
diff changeset
   190
    }
hgs
parents:
diff changeset
   191
    CxeError::Id err = CxeError::None;
hgs
parents:
diff changeset
   192
hgs
parents:
diff changeset
   193
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
    return err;
hgs
parents:
diff changeset
   196
}
hgs
parents:
diff changeset
   197
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
hgs
parents:
diff changeset
   200
/*!
hgs
parents:
diff changeset
   201
* resets the cenrep store
hgs
parents:
diff changeset
   202
*/
hgs
parents:
diff changeset
   203
void CxeSettingsStoreDesktop::reset()
hgs
parents:
diff changeset
   204
{
hgs
parents:
diff changeset
   205
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents:
diff changeset
   206
    //!@Todo: How to reset the repository.
hgs
parents:
diff changeset
   207
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents:
diff changeset
   208
}
hgs
parents:
diff changeset
   209
hgs
parents:
diff changeset
   210
// end of file