|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Manages all static settings data. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CAMSTATICSETTINGSMODEL_H |
|
21 #define CAMSTATICSETTINGSMODEL_H |
|
22 |
|
23 // INCLUDES |
|
24 // Internal build flags, keep first. |
|
25 |
|
26 #include <eikenv.h> |
|
27 #include <centralrepository.h> |
|
28 #include "Cam.hrh" |
|
29 #include "mcamsettingsmodel.h" |
|
30 #include "MCamStaticSettings.h" |
|
31 #include "CamSettingsInternal.hrh" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 |
|
35 class CCamConfiguration; |
|
36 class CCameraUiConfigManager; |
|
37 |
|
38 /** |
|
39 * Manages all static settings data. |
|
40 * @since 2.8 |
|
41 */ |
|
42 class CCamStaticSettingsModel : public CBase, |
|
43 public MCamStaticSettings |
|
44 { |
|
45 // ========================================================================= |
|
46 public: // Constructors and destructor |
|
47 |
|
48 /** |
|
49 * Symbian two-phased constructor. |
|
50 * @since 2.8 |
|
51 * @param aConfiguration |
|
52 * engine changes. |
|
53 */ |
|
54 static CCamStaticSettingsModel* NewLC( CCamConfiguration& aConfiguration ); |
|
55 |
|
56 /** |
|
57 * Symbian two-phased constructor. |
|
58 * @since 2.8 |
|
59 * @param aConfiguration |
|
60 * engine changes. |
|
61 */ |
|
62 static CCamStaticSettingsModel* NewL( CCamConfiguration& aConfiguration ); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 ~CCamStaticSettingsModel(); |
|
68 |
|
69 public: // New Fuctions |
|
70 |
|
71 /** |
|
72 * Returns the current integer value for the specified setting |
|
73 * @return the current integer setting value |
|
74 * @param aSettingItem specifies which setting item that want the value of. |
|
75 * @since 2.8 |
|
76 */ |
|
77 TInt IntegerSettingValue( TInt aSettingItem ) const; |
|
78 |
|
79 /** |
|
80 * Sets a new value for the specified integer setting |
|
81 * @param aSettingItem specifies which setting item that want to set the value of. |
|
82 * @param aSettingValue the new integer value for the specified setting item. |
|
83 * @since 2.8 |
|
84 */ |
|
85 void SetIntegerSettingValueL( TInt aSettingItem, TInt aSettingValue ); |
|
86 |
|
87 /** |
|
88 * Sets a new text value for the specified setting |
|
89 * @param aSettingItem specifies which setting item that want to set the text value of. |
|
90 * @param aSettingValue the new text value for the specified setting item. |
|
91 * @since 2.8 |
|
92 */ |
|
93 void SetTextSettingValueL( TInt aSettingItem, |
|
94 const TDesC& aSettingValue ); |
|
95 |
|
96 /** |
|
97 * Returns the current text value for the specified setting |
|
98 * @return the current text setting value |
|
99 * @param aSettingItem specifies which setting item that want the text value of. |
|
100 * @since 2.8 |
|
101 */ |
|
102 TPtrC TextSettingValue( TInt aSettingItem ) const; |
|
103 |
|
104 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
105 /** |
|
106 * Loads the static settings from shared data. Required to update |
|
107 * the settings whenever get foreground event, in case of external |
|
108 * changes to the settings. |
|
109 * @since 2.8 |
|
110 * @param aIsEmbedded Specifies whether the application is embedded |
|
111 * or not. |
|
112 */ |
|
113 void LoadStaticSettingsL( TBool aIsEmbedded ); |
|
114 |
|
115 #endif //CAMERAAPP_PLUGIN_BUILD |
|
116 |
|
117 /** |
|
118 * Reads the specified key from the Central Repository, returns the |
|
119 * content in HBufC |
|
120 * |
|
121 * @since 5.0 |
|
122 * @param aCenRepKeyId The Central Repository key id to read |
|
123 */ |
|
124 HBufC* ReadCenRepStringL( TInt aCenRepKeyId ); |
|
125 /* |
|
126 * Reset repository file |
|
127 * @since3.0 |
|
128 */ |
|
129 void ResetRepository(); |
|
130 |
|
131 /** |
|
132 * Loads the image/common static settings from shared data. Required to update |
|
133 * the settings whenever get foreground event, in case of external |
|
134 * changes to the settings. |
|
135 */ |
|
136 void LoadPhotoStaticSettingsL( const TBool aResetFromPlugin ); |
|
137 |
|
138 /** |
|
139 * Loads the video/common static settings from shared data. Required to update |
|
140 * the settings whenever get foreground event, in case of external |
|
141 * changes to the settings. |
|
142 */ |
|
143 void LoadVideoStaticSettingsL( const TBool aResetFromPlugin ); |
|
144 |
|
145 // New methods |
|
146 public: |
|
147 |
|
148 /** |
|
149 * Reads the specified setting from the Central Repository, and |
|
150 * stores the new setting object in the array. |
|
151 * @since 3.0 |
|
152 * @param TCamSettingItemIds the settings range for static settings from CamSettingsInternals.hrh |
|
153 * @param TCamSettingItemIds the settings range for static settings from CamSettingsInternals.hrh |
|
154 * @param aArray The array to add the setting to |
|
155 */ |
|
156 void ReadFromCenRepL( const TInt aMinRange, |
|
157 const TInt aMaxRange, |
|
158 RPointerArray <TIntSetting>& aArray ); |
|
159 |
|
160 /** |
|
161 * Reads the specified setting from the Central Repository, and |
|
162 * stores the new setting object in the array. |
|
163 * @since 3.0 |
|
164 * @param aUiId The Settings Model ID to be loaded to the array |
|
165 * @param aCenRepID The Central Repository setting ID to read |
|
166 * @param aArray The array to add the setting to |
|
167 */ |
|
168 void ReadCenRepIntL( TCamSettingItemIds aUiId, |
|
169 TInt aCenRepID, |
|
170 RPointerArray <TIntSetting>& aArray ); |
|
171 |
|
172 |
|
173 /** |
|
174 * Saves the setting item from the array to the Central Repository. |
|
175 * May leave with KErrNotFound if the item id 'aItemId' is not found |
|
176 * in the array 'aArray'. |
|
177 * @since 3.0 |
|
178 * @param aItemId The Settings Model ID to be saved |
|
179 * @param aCenRepID The Central Repository setting ID to saved to |
|
180 * @param aArray The array to read the setting from |
|
181 */ |
|
182 void SaveCenRepItemL( TCamSettingItemIds aItemId, |
|
183 TInt aCenRepId, |
|
184 const RPointerArray<TIntSetting>& aArray ); |
|
185 |
|
186 /** |
|
187 * Saves one static setting to Central Repository. |
|
188 * @param aSettingId Id of the setting to be saved. |
|
189 * @since Camera 4.0 |
|
190 */ |
|
191 void SaveStaticSettingL( TCamSettingItemIds aSettingId ); |
|
192 |
|
193 /** |
|
194 * Stores the primary camera settings when changing to secondary camera |
|
195 * that they can be reapplied when changing back |
|
196 * @since 2.8 |
|
197 */ |
|
198 void StorePrimaryCameraSettingsL(); |
|
199 |
|
200 /** |
|
201 * Restores the primary camera settings |
|
202 * @since 2.8 |
|
203 */ |
|
204 void RestorePrimaryCameraSettingsL(); |
|
205 |
|
206 /* |
|
207 * Resets a particular setting item value |
|
208 */ |
|
209 void ResetSettingItem( const TInt aSettingItem ); |
|
210 |
|
211 /** |
|
212 * Get the associated Central Repository Key for given setting item. |
|
213 * @param aSettingId Id of the setting for which the key is requested. |
|
214 * @param aEmbedded Is request made for embedded mode setting or not. |
|
215 * @since Camera 4.0 |
|
216 */ |
|
217 static TUint32 MapSettingItem2CRKey( TCamSettingItemIds aSettingId, |
|
218 TBool aEmbedded ); |
|
219 |
|
220 /** |
|
221 * Get the associated settings list for given setting item. |
|
222 * @param aSettingId Id of the setting for which the list is requested. |
|
223 * @since Camera 4.0 |
|
224 */ |
|
225 RPointerArray<TIntSetting>* |
|
226 MapSettingItem2SettingsList( TCamSettingItemIds aSettingId ); |
|
227 |
|
228 /** |
|
229 * Removes any previously loaded static settings. |
|
230 * @since 2.8 |
|
231 */ |
|
232 void UnloadStaticSettings(); |
|
233 |
|
234 /** |
|
235 * Loads a list of dynamic settings from the resource file |
|
236 * @param aResourceId the id of the resource that contains the |
|
237 * settings items id's and their default values. |
|
238 * @param aSettingsList the list to populate with dynamic settings |
|
239 * from the resource file. |
|
240 * @since 2.8 |
|
241 */ |
|
242 void LoadSettingsFromResourceL( TInt aResourceId, |
|
243 RPointerArray<TIntSetting>& aSettingsList ); |
|
244 |
|
245 /** |
|
246 * Returns reference to CCamConfiguration object describing |
|
247 * the device's camera configuration. |
|
248 * @return configuration |
|
249 */ |
|
250 CCamConfiguration& Configuration() const; |
|
251 |
|
252 /* |
|
253 * Handle to Camera Ui Config Manager |
|
254 */ |
|
255 CCameraUiConfigManager* UiConfigManagerPtr(); |
|
256 |
|
257 private: |
|
258 |
|
259 // |
|
260 // CCamStaticSettingsModel::LoadCommonStaticSettingsL |
|
261 // |
|
262 void LoadCommonStaticSettingsL( const TBool aResetFromPlugin ); |
|
263 |
|
264 /* |
|
265 * Searches for a setting item in the list of available list of items |
|
266 */ |
|
267 TInt SearchInSettingsListFor( |
|
268 const RPointerArray<TIntSetting>& aSettingsList, |
|
269 TInt aSettingItem ) const; |
|
270 |
|
271 /** |
|
272 * Saves the static settings to shared data. |
|
273 * @since 2.8 |
|
274 */ |
|
275 void SaveSettingsL(); |
|
276 |
|
277 /* |
|
278 * Load embedded camera specific settings |
|
279 */ |
|
280 void LoadEmbeddedSettingsL(); |
|
281 |
|
282 // Constructors |
|
283 private: |
|
284 |
|
285 /** |
|
286 * C++ constructor. |
|
287 * @since 2.8 |
|
288 * @param aConfiguration |
|
289 */ |
|
290 CCamStaticSettingsModel( CCamConfiguration& aConfiguration ); |
|
291 |
|
292 /** |
|
293 * C++ 2nd phase constructor. |
|
294 * @since 2.8 |
|
295 */ |
|
296 void ConstructL(); |
|
297 |
|
298 /** |
|
299 * Loads photo base name |
|
300 * @since 2.8 |
|
301 */ |
|
302 void LoadPhotoBaseNameL(); |
|
303 |
|
304 /** |
|
305 * Loads video base name |
|
306 * @since 2.8 |
|
307 */ |
|
308 void LoadVideoBaseNameL(); |
|
309 |
|
310 /** |
|
311 * Saves photo base name |
|
312 * @since 2.8 |
|
313 */ |
|
314 void SavePhotoBaseNameL(); |
|
315 |
|
316 /** |
|
317 * Saves video base name |
|
318 * @since 2.8 |
|
319 */ |
|
320 void SaveVideoBaseNameL(); |
|
321 |
|
322 /** |
|
323 * Saves name of the DefaultAlbum |
|
324 */ |
|
325 void SaveDefaultAlbumNameL(); |
|
326 |
|
327 /** |
|
328 * Loads name of the DefaultAlbum |
|
329 */ |
|
330 void LoadDefaultAlbumNameL(); |
|
331 |
|
332 private: // data |
|
333 |
|
334 /** |
|
335 * Stores information for front/back camera settings |
|
336 * @since 2.8 |
|
337 */ |
|
338 class TCamCameraSettings |
|
339 { |
|
340 public: |
|
341 TInt iPhotoQuality; |
|
342 TInt iVideoQuality; |
|
343 }; |
|
344 |
|
345 // Commom static settings. |
|
346 RPointerArray<TIntSetting> iStaticCommonIntSettings; |
|
347 |
|
348 // List of setting item id/value pairs for static photo settings. |
|
349 RPointerArray<TIntSetting> iStaticPhotoIntSettings; |
|
350 |
|
351 // List of setting item id/value pairs for static video settings. |
|
352 RPointerArray<TIntSetting> iStaticVideoIntSettings; |
|
353 |
|
354 // Video file base name. |
|
355 TBuf<KMaxNameBaseLength> iVideoBaseName; |
|
356 |
|
357 // Photo file base name. |
|
358 TBuf<KMaxNameBaseLength> iPhotoBaseName; |
|
359 |
|
360 TBuf<KMaxAlbumNameLength> iDefaultAlbumName; |
|
361 |
|
362 // Specifies whether this application is embedded or not. |
|
363 TBool iEmbedded; |
|
364 |
|
365 // Handle to actual setting storage object |
|
366 CRepository* iRepository; |
|
367 |
|
368 // The cached primary camera settings |
|
369 TCamCameraSettings iPrimaryCameraSettings; |
|
370 // The cached secondary camera settings |
|
371 TCamCameraSettings iSecondaryCameraSettings; |
|
372 CCamConfiguration& iConfiguration; |
|
373 CCameraUiConfigManager* iConfigManager; |
|
374 }; |
|
375 |
|
376 #endif // CAMSETTINGSMODEL_H |
|
377 |
|
378 // End of File |