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