|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Symbian specific settings handling |
|
19 */ |
|
20 |
|
21 #include <QCoreApplication> |
|
22 #include <QVariant> |
|
23 #include <QList> |
|
24 #include <QMetaType> |
|
25 #include <ecam.h> |
|
26 #include <ecamadvsettingsuids.hrh> |
|
27 #include <ecamadvsettings.h> |
|
28 #include <QObject> |
|
29 |
|
30 #include "cxesettingsmodel.h" |
|
31 #include "cxesettingsimp.h" |
|
32 #include "cxesettings.h" |
|
33 #include "cxutils.h" |
|
34 #include "cxenamespace.h" |
|
35 #include "cxeerror.h" |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 /*! |
|
42 Load image/video specific settings during mode change or startup |
|
43 */ |
|
44 void CxeSettingsImp::loadSettings(Cxe::CameraMode mode) |
|
45 { |
|
46 CX_DEBUG_ENTER_FUNCTION(); |
|
47 |
|
48 // inform the settings model for the change in mode. |
|
49 mSettingsModel.cameraModeChanged(mode); |
|
50 |
|
51 if (mode == Cxe::ImageMode) { |
|
52 emit sceneChanged(mSettingsModel.currentImageScene()); |
|
53 } else { |
|
54 emit sceneChanged(mSettingsModel.currentVideoScene()); |
|
55 } |
|
56 |
|
57 CX_DEBUG_EXIT_FUNCTION(); |
|
58 } |
|
59 |
|
60 |
|
61 |
|
62 /*! |
|
63 Return the current integer setting value for the given key |
|
64 */ |
|
65 CxeError::Id CxeSettingsImp::get(const QString& key, int& value) const |
|
66 { |
|
67 CX_DEBUG_ENTER_FUNCTION(); |
|
68 |
|
69 QVariant v; |
|
70 CxeError::Id err = mSettingsModel.getSettingValue(key, v); |
|
71 |
|
72 bool isInt; |
|
73 value = v.toInt(&isInt); // 0 denotes base, check the API |
|
74 |
|
75 if (isInt) { |
|
76 CX_DEBUG(("CxeSettingsImp::get - key: %s value: %d", |
|
77 key.toAscii().data(), value )); |
|
78 } else { |
|
79 err = CxeError::NotSupported; |
|
80 } |
|
81 |
|
82 CX_DEBUG_EXIT_FUNCTION(); |
|
83 |
|
84 return err; |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 /*! |
|
91 Return the current real setting value for the given key |
|
92 */ |
|
93 CxeError::Id CxeSettingsImp::get(const QString &key, qreal &value) const |
|
94 { |
|
95 CX_DEBUG_ENTER_FUNCTION(); |
|
96 |
|
97 QVariant v; |
|
98 CxeError::Id err = mSettingsModel.getSettingValue(key, v); |
|
99 |
|
100 bool isReal; |
|
101 value = v.toReal(&isReal); |
|
102 |
|
103 if (isReal) { |
|
104 CX_DEBUG(("CxeSettingsImp::get - key: %s value: %f", |
|
105 key.toAscii().data(), value )); |
|
106 } else { |
|
107 err = CxeError::NotSupported; |
|
108 } |
|
109 |
|
110 CX_DEBUG_EXIT_FUNCTION(); |
|
111 |
|
112 return err; |
|
113 } |
|
114 |
|
115 |
|
116 /*! |
|
117 Return the current string setting value for the given key |
|
118 */ |
|
119 CxeError::Id CxeSettingsImp::get( |
|
120 const QString& key, QString &stringValue) const |
|
121 { |
|
122 CX_DEBUG_ENTER_FUNCTION(); |
|
123 |
|
124 QVariant value; |
|
125 CxeError::Id err = getSceneMode(key, stringValue); |
|
126 |
|
127 if (err == CxeError::NotFound) { |
|
128 // read from settings store |
|
129 err = mSettingsModel.getSettingValue(key, value); |
|
130 stringValue = value.toString(); |
|
131 } |
|
132 |
|
133 CX_DEBUG(("CxeSettingsImp::get - key: %s value: %s", |
|
134 key.toAscii().data(), stringValue.toAscii().data())); |
|
135 CX_DEBUG_EXIT_FUNCTION(); |
|
136 |
|
137 return err; |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 /* |
|
143 * Reads a value from cenrep |
|
144 * @param key - setting key |
|
145 * @param uid - setting UID of the component that owns the setting key |
|
146 * @param type - the type of key cr key or P&S key (constantly monitoring value) |
|
147 * @param value - setting value read from cenrep |
|
148 */ |
|
149 |
|
150 void CxeSettingsImp::get(long int uid, |
|
151 unsigned long int key, |
|
152 Cxe::SettingKeyType type, |
|
153 QVariant &value) const |
|
154 { |
|
155 CX_DEBUG_ENTER_FUNCTION(); |
|
156 |
|
157 mSettingsModel.getSettingValue(uid, key, type, value); |
|
158 |
|
159 CX_DEBUG_EXIT_FUNCTION(); |
|
160 |
|
161 } |
|
162 |
|
163 |
|
164 |
|
165 /*! |
|
166 Get the current scene mode setting value for the given key |
|
167 */ |
|
168 CxeError::Id CxeSettingsImp::getSceneMode( |
|
169 const QString& key, QString &stringValue) const |
|
170 { |
|
171 CX_DEBUG_ENTER_FUNCTION(); |
|
172 |
|
173 CxeError::Id err = CxeError::None; |
|
174 CxeScene scene; |
|
175 |
|
176 if(CxeSettingIds::IMAGE_SCENE == key) { |
|
177 scene = mSettingsModel.currentImageScene(); |
|
178 } else if(CxeSettingIds::VIDEO_SCENE == key) { |
|
179 scene = mSettingsModel.currentVideoScene(); |
|
180 } else { |
|
181 err = CxeError::NotFound; |
|
182 } |
|
183 |
|
184 if (err == CxeError::None) { |
|
185 stringValue = scene["sceneId"].toString(); |
|
186 } |
|
187 |
|
188 CX_DEBUG(("CxeSettingsImp::get - key: %s value: %s", |
|
189 key.toAscii().data(), stringValue.toAscii().data())); |
|
190 |
|
191 CX_DEBUG_EXIT_FUNCTION(); |
|
192 |
|
193 return err; |
|
194 } |
|
195 |
|
196 |
|
197 /*! |
|
198 Set new int value for the given key |
|
199 */ |
|
200 CxeError::Id CxeSettingsImp::set(const QString& key,int newValue) |
|
201 { |
|
202 CX_DEBUG_ENTER_FUNCTION(); |
|
203 |
|
204 CX_DEBUG(("CxeSettingsImp::set - key: %s value: %d", |
|
205 key.toAscii().data(), newValue)); |
|
206 |
|
207 CxeError::Id err = mSettingsModel.set(key, newValue); |
|
208 emit settingValueChanged(key, newValue); |
|
209 |
|
210 CX_DEBUG_EXIT_FUNCTION(); |
|
211 |
|
212 return err; |
|
213 } |
|
214 |
|
215 |
|
216 |
|
217 /*! |
|
218 Set new int value for the given key |
|
219 */ |
|
220 CxeError::Id CxeSettingsImp::set(const QString& key,qreal newValue) |
|
221 { |
|
222 CX_DEBUG_ENTER_FUNCTION(); |
|
223 |
|
224 CX_DEBUG(("CxeSettingsImp::set - key: %s value: %f", |
|
225 key.toAscii().data(), newValue)); |
|
226 |
|
227 CxeError::Id err = mSettingsModel.set(key, newValue); |
|
228 emit settingValueChanged(key, newValue); |
|
229 |
|
230 CX_DEBUG_EXIT_FUNCTION(); |
|
231 |
|
232 return err; |
|
233 } |
|
234 |
|
235 |
|
236 /*! |
|
237 Set new string value for the given key |
|
238 */ |
|
239 CxeError::Id CxeSettingsImp::set(const QString& key,const QString& newValue) |
|
240 { |
|
241 CX_DEBUG_ENTER_FUNCTION(); |
|
242 |
|
243 CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s", |
|
244 key.toAscii().data(), newValue.toAscii().data())); |
|
245 |
|
246 CxeError::Id err = setSceneMode(key, newValue); |
|
247 |
|
248 if (err == CxeError::NotFound) { |
|
249 // not scene mode setting, try setting value to settings store |
|
250 mSettingsModel.set(key, newValue); |
|
251 emit settingValueChanged(key, newValue); |
|
252 } |
|
253 |
|
254 CX_DEBUG_EXIT_FUNCTION(); |
|
255 |
|
256 return err; |
|
257 } |
|
258 |
|
259 |
|
260 |
|
261 /*! |
|
262 Set the current scene mode setting value for the given key |
|
263 */ |
|
264 CxeError::Id CxeSettingsImp::setSceneMode( |
|
265 const QString& key,const QString& newValue) |
|
266 { |
|
267 CX_DEBUG_ENTER_FUNCTION(); |
|
268 |
|
269 CX_DEBUG(("CxeSettingsImp::set - key: %s value: %s", |
|
270 key.toAscii().data(), newValue.toAscii().data())); |
|
271 |
|
272 CxeError::Id err = CxeError::None; |
|
273 CxeScene scene; |
|
274 |
|
275 if(CxeSettingIds::IMAGE_SCENE == key) { |
|
276 err = mSettingsModel.setImageScene(newValue); |
|
277 scene = mSettingsModel.currentImageScene(); |
|
278 } else if(CxeSettingIds::VIDEO_SCENE == key) { |
|
279 err = mSettingsModel.setVideoScene(newValue); |
|
280 scene = mSettingsModel.currentVideoScene(); |
|
281 } else { |
|
282 err = CxeError::NotFound; |
|
283 } |
|
284 |
|
285 if (err == CxeError::None) { |
|
286 // scene mode set, inform clients about scene mode change |
|
287 emit sceneChanged(scene); |
|
288 } |
|
289 |
|
290 CX_DEBUG_EXIT_FUNCTION(); |
|
291 |
|
292 return err; |
|
293 } |
|
294 |
|
295 /*! |
|
296 Reset static settings (persistent settings) |
|
297 */ |
|
298 void CxeSettingsImp::reset() |
|
299 { |
|
300 CX_DEBUG_ENTER_FUNCTION(); |
|
301 |
|
302 mSettingsModel.reset(); |
|
303 |
|
304 CX_DEBUG_EXIT_FUNCTION(); |
|
305 } |
|
306 |
|
307 |
|
308 |
|
309 /* |
|
310 * CxeSettingsImp::CxeSettingsImp |
|
311 */ |
|
312 CxeSettingsImp::CxeSettingsImp(CxeSettingsModel& settingsModel) |
|
313 : mSettingsModel(settingsModel) |
|
314 { |
|
315 CX_DEBUG_IN_FUNCTION(); |
|
316 } |
|
317 |
|
318 |
|
319 |
|
320 /* |
|
321 * CxeSettingsImp::close |
|
322 */ |
|
323 CxeSettingsImp::~CxeSettingsImp() |
|
324 { |
|
325 CX_DEBUG_IN_FUNCTION(); |
|
326 } |
|
327 |
|
328 // end of file |