|
1 /* |
|
2 * Copyright (c) 2009-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QVariant> |
|
19 #include <QList> |
|
20 #include <QHash> |
|
21 |
|
22 #include "cxenamespace.h" |
|
23 #include "cxefakesettingsstore.h" |
|
24 |
|
25 CxeFakeSettingsStore::CxeFakeSettingsStore() |
|
26 { |
|
27 resetSettings(); |
|
28 } |
|
29 |
|
30 CxeFakeSettingsStore::~CxeFakeSettingsStore() |
|
31 { |
|
32 } |
|
33 |
|
34 void CxeFakeSettingsStore::resetSettings() |
|
35 { |
|
36 // This part should be synchronized with the current settings |
|
37 // supported by camera and defined in cxenamespace |
|
38 mSettingKeyHash.clear(); |
|
39 mSettingKeyHash.insert(CxeSettingIds::FNAME_FOLDER_SUFFIX, QVariant("_Nokia")); |
|
40 mSettingKeyHash.insert(CxeSettingIds::FNAME_MONTH_FOLDER, QVariant("08042009")); |
|
41 mSettingKeyHash.insert(CxeSettingIds::FNAME_IMAGE_COUNTER, QVariant(0)); |
|
42 mSettingKeyHash.insert(CxeSettingIds::FNAME_VIDEO_COUNTER, QVariant(0)); |
|
43 |
|
44 mSettingKeyHash.insert(CxeSettingIds::CAMERA_MODE, QVariant(0)); |
|
45 mSettingKeyHash.insert(CxeSettingIds::FLASH_MODE, QVariant(0)); |
|
46 mSettingKeyHash.insert(CxeSettingIds::IMAGE_SCENE, QVariant("image_scene_auto")); |
|
47 mSettingKeyHash.insert(CxeSettingIds::VIDEO_SCENE, QVariant("video_scene_auto")); |
|
48 mSettingKeyHash.insert(CxeSettingIds::STILL_SHOWCAPTURED, QVariant(0)); |
|
49 mSettingKeyHash.insert(CxeSettingIds::VIDEO_SHOWCAPTURED, QVariant(0)); |
|
50 mSettingKeyHash.insert(CxeSettingIds::VIDEO_MUTE_SETTING, QVariant(0)); |
|
51 |
|
52 mSettingKeyHash.insert(CxeSettingIds::GEOTAGGING, QVariant(0)); |
|
53 mSettingKeyHash.insert(CxeSettingIds::GEOTAGGING_DISCLAIMER, QVariant(1)); |
|
54 mSettingKeyHash.insert(CxeSettingIds::FACE_TRACKING, QVariant(1)); |
|
55 mSettingKeyHash.insert(CxeSettingIds::IMAGE_QUALITY, QVariant(0)); |
|
56 mSettingKeyHash.insert(CxeSettingIds::VIDEO_QUALITY, QVariant(0)); |
|
57 |
|
58 mSettingKeyHash.insert(CxeSettingIds::FOCAL_RANGE, QVariant(0)); |
|
59 mSettingKeyHash.insert(CxeSettingIds::WHITE_BALANCE, QVariant(0)); |
|
60 mSettingKeyHash.insert(CxeSettingIds::LIGHT_SENSITIVITY, QVariant(0)); |
|
61 mSettingKeyHash.insert(CxeSettingIds::EXPOSURE_MODE, QVariant(0)); |
|
62 mSettingKeyHash.insert(CxeSettingIds::SHARPNESS, QVariant(0)); |
|
63 mSettingKeyHash.insert(CxeSettingIds::COLOR_TONE, QVariant(0)); |
|
64 mSettingKeyHash.insert(CxeSettingIds::EV_COMPENSATION_VALUE, QVariant(0)); |
|
65 mSettingKeyHash.insert(CxeSettingIds::CONTRAST, QVariant(0)); |
|
66 mSettingKeyHash.insert(CxeSettingIds::BRIGHTNESS, QVariant(0)); |
|
67 mSettingKeyHash.insert(CxeSettingIds::FRAME_RATE, QVariant(0)); |
|
68 mSettingKeyHash.insert(CxeSettingIds::SCENE_ID, QVariant(0)); |
|
69 mSettingKeyHash.insert(CxeSettingIds::SECONDARY_CAMERA, QVariant(0)); |
|
70 mSettingKeyHash.insert(CxeSettingIds::SELF_TIMER, QVariant(0)); |
|
71 mSettingKeyHash.insert(CxeSettingIds::CAPTURE_SOUND_ALWAYS_ON, QVariant(0)); |
|
72 } |
|
73 |
|
74 /*! |
|
75 * Reads a value from cenrep |
|
76 * @param "key" - setting key |
|
77 * @param "value" - setting value read from cenrep |
|
78 */ |
|
79 CxeError::Id CxeFakeSettingsStore::get(const QString& key, QVariant &value) |
|
80 { |
|
81 CxeError::Id error = CxeError::None; |
|
82 if(mSettingKeyHash.contains(key)) { |
|
83 value = mSettingKeyHash[key]; |
|
84 } else if(mVariationKeyHash.contains(key)) { |
|
85 value = mVariationKeyHash[key]; |
|
86 } else { |
|
87 error = CxeError::NotFound; |
|
88 } |
|
89 |
|
90 return error; |
|
91 } |
|
92 |
|
93 /*! |
|
94 * Reads a value from cenrep |
|
95 * @param "uid" - UID of the component that own setting key |
|
96 * @param "key" - setting key id |
|
97 * @param "type" - type of setting key |
|
98 * @param "value" - setting value read from cenrep |
|
99 */ |
|
100 void CxeFakeSettingsStore::startMonitoring(long int uid, unsigned long int key, Cxe::SettingKeyType type, QVariant &value) |
|
101 { |
|
102 Q_UNUSED(uid); |
|
103 Q_UNUSED(key); |
|
104 Q_UNUSED(type); |
|
105 |
|
106 // Instead of emulating cenrep functionality |
|
107 // we just return a test value for verification |
|
108 value = 42; |
|
109 } |
|
110 |
|
111 /*! |
|
112 * Reads/loads all variation settings values from cenrep |
|
113 * @param QList<QString> contains list of all variation key ids which we use to load values from cenrep. |
|
114 * returns: QHash container, "contains" values associated with each key that are read from cenrep |
|
115 * NOTE: loading variation settings should be done only ONCE at start-up. |
|
116 */ |
|
117 QHash<QString, QVariantList> CxeFakeSettingsStore::loadVariationSettings(QList<QString> &settingKeys) |
|
118 { |
|
119 QVariant data; |
|
120 CxeError::Id err = CxeError::None; |
|
121 QVariantList list; |
|
122 QHash<QString, QVariantList> settings; |
|
123 mVariationKeyHash.clear(); |
|
124 |
|
125 foreach (QString key, settingKeys) { |
|
126 |
|
127 // before we read from get function we set values to the key |
|
128 mVariationKeyHash.insert(key, QVariant(1)); |
|
129 |
|
130 // read the data from cenrep |
|
131 err = get(key, data); |
|
132 // clear the list |
|
133 list.clear(); |
|
134 if (CxeError::None == err) { |
|
135 list.append(data); |
|
136 } |
|
137 // append the values associated with the key to the list. |
|
138 settings.insert(key, list); |
|
139 } // end for |
|
140 |
|
141 return settings; |
|
142 } |
|
143 |
|
144 |
|
145 /*! |
|
146 * Sets a new value to cenrep |
|
147 * @param "key" - setting key |
|
148 * @param "newValue" - new value set to the key in cenrep |
|
149 */ |
|
150 CxeError::Id CxeFakeSettingsStore::set(const QString& key, const QVariant newValue) |
|
151 { |
|
152 CxeError::Id error = CxeError::NotFound; |
|
153 if(mSettingKeyHash.contains(key)) { |
|
154 mSettingKeyHash[key] = newValue; |
|
155 error = CxeError::None; |
|
156 } |
|
157 return error; |
|
158 } |
|
159 |
|
160 /*! |
|
161 * resets the cenrep store |
|
162 */ |
|
163 void CxeFakeSettingsStore::reset() |
|
164 { |
|
165 resetSettings(); |
|
166 } |
|
167 |