1 /* |
|
2 * Copyright (c) 2007-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: Manages all settings data.* |
|
15 */ |
|
16 |
|
17 |
|
18 // =========================================================================== |
|
19 // Includes |
|
20 #include <StringLoader.h> |
|
21 #include <barsread.h> |
|
22 #include <AknQueryDialog.h> |
|
23 #include <ecam.h> |
|
24 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
25 |
|
26 #include <cameraapp.rsg> |
|
27 #include <vgacamsettings.rsg> |
|
28 |
|
29 #include "CamSettingsModel.h" |
|
30 #include "CamPanic.h" |
|
31 #include "mcamsettingsmodelobserver.h" |
|
32 #include "CamAppUiBase.h" |
|
33 #include "CamSharedDataKeys.h" |
|
34 #include "CamUtility.h" |
|
35 #include "CamVideoQualityLevel.h" |
|
36 |
|
37 #include "CameraVariant.hrh" // Variant CR key values |
|
38 #include "CameraappPrivateCRKeys.h" // CR keys |
|
39 #include "camactivepalettehandler.h" |
|
40 #include "CamAppUi.h" |
|
41 #include "camsettingconversion.h" |
|
42 #include "camconfiguration.h" |
|
43 #include "CamStaticSettingsModel.h" |
|
44 #include "CameraUiConfigManager.h" |
|
45 |
|
46 // =========================================================================== |
|
47 // Constants |
|
48 |
|
49 const TInt KDynamicArrayGranularity = 3; |
|
50 _LIT( KCamNhdResourceFileName, "z:nhdcamsettings.rss" ); |
|
51 _LIT( KCamVgaResourceFileName, "z:vgacamsettings.rss" ); |
|
52 |
|
53 |
|
54 // =========================================================================== |
|
55 // Local methods |
|
56 inline TBool SettingIdMatches( const TInt* aSettingId, |
|
57 const TIntSetting& aSettingItem ) |
|
58 { |
|
59 return (*aSettingId == aSettingItem.iItemId); |
|
60 }; |
|
61 |
|
62 inline TInt FindIndex( const RPointerArray<TIntSetting>& aSettingArray, |
|
63 const TInt& aSettingId ) |
|
64 { |
|
65 return aSettingArray.Find( aSettingId, SettingIdMatches ); |
|
66 }; |
|
67 |
|
68 inline TInt FindIndex( const RPointerArray<TIntSetting>& aSettingArray, |
|
69 const TIntSetting& aSettingItem ) |
|
70 { |
|
71 return FindIndex( aSettingArray, aSettingItem.iItemId ); |
|
72 }; |
|
73 |
|
74 |
|
75 // =========================================================================== |
|
76 // Class methods |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // TCamVariantInfo constructor |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TCamVariantInfo::TCamVariantInfo() |
|
84 : iFlags ( -1 ), |
|
85 iTimeLapseSupport( ECamSupportUnknown ), |
|
86 iAlwaysOnSupport ( ECamSupportUnknown ), |
|
87 iVersion ( -1, 0, 0 ) |
|
88 { |
|
89 } |
|
90 |
|
91 // =========================================================================== |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CCamSettingsModel::NewL |
|
95 // Symbian OS two-phased constructor |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CCamSettingsModel* CCamSettingsModel::NewL( CCamConfiguration& aConfiguration ) |
|
99 { |
|
100 CCamSettingsModel* self = CCamSettingsModel::NewLC( aConfiguration ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CCamSettingsModel::NewLC |
|
107 // Symbian OS two-phased constructor |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CCamSettingsModel* CCamSettingsModel::NewLC( CCamConfiguration& aConfiguration ) |
|
111 { |
|
112 CCamSettingsModel* self = new( ELeave ) CCamSettingsModel( aConfiguration ); |
|
113 CleanupStack::PushL( self ); |
|
114 self->ConstructL(); |
|
115 return self; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CCamSettingsModel::ResetUserSceneWithoutActivatingChangesL |
|
120 // Resets all user scene settings to their defaults without activating them. |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CCamSettingsModel::ResetUserSceneWithoutActivatingChangesL() |
|
124 { |
|
125 PRINT( _L("Camera => CCamSettingsModel::ResetUserSceneWithoutActivatingChangesL")) |
|
126 |
|
127 // Reset the user scene data in the repository |
|
128 iStaticModel->ResetSettingItem( KCamCrUserSceneBaseScene ); |
|
129 iStaticModel->ResetSettingItem( KCamCrUserSceneWhiteBalance ); |
|
130 iStaticModel->ResetSettingItem( KCamCrUserSceneColourFilter ); |
|
131 iStaticModel->ResetSettingItem( KCamCrUserSceneFlash ); |
|
132 iStaticModel->ResetSettingItem( KCamCrUserSceneExposure ); |
|
133 |
|
134 if ( iUiConfigManager->IsISOSupported() ) |
|
135 { |
|
136 iStaticModel->ResetSettingItem( KCamCrUserSceneLightSensitivity ); |
|
137 } |
|
138 iStaticModel->ResetSettingItem( KCamCrUserSceneContrast ); |
|
139 iStaticModel->ResetSettingItem( KCamCrUserSceneImageSharpness ); |
|
140 |
|
141 // Reload the static user scene settings |
|
142 iUserSceneSettings.ResetAndDestroy(); |
|
143 iStaticModel->ReadFromCenRepL( |
|
144 static_cast<TInt>( ECamSettingItemUserSceneRangeMin ), |
|
145 static_cast<TInt>( ECamSettingItemUserSceneRangeMax ), |
|
146 iUserSceneSettings |
|
147 ); |
|
148 PRINT( _L("Camera <= CCamSettingsModel::ResetUserSceneWithoutActivatingChangesL")) |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CCamSettingsModel::ResetUserSceneL |
|
153 // Resets all user scene settings to their defaults. |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CCamSettingsModel::ResetUserSceneL() |
|
157 { |
|
158 PRINT( _L("Camera => CCamSettingsModel::ResetUserSceneL")) |
|
159 // Reset the user scene based on scene in the repository to get the default value |
|
160 ResetUserSceneWithoutActivatingChangesL(); |
|
161 TInt scene = IntegerSettingValue( ECamSettingItemDynamicPhotoScene ); |
|
162 // If current scene is user scene |
|
163 if ( ECamSceneUser == scene ) |
|
164 { |
|
165 // if the user scene is currently the photo scene then |
|
166 // activate all the default scene settings to the AP |
|
167 ActivateUserSceneSettingsL(); |
|
168 } |
|
169 PRINT( _L("Camera <= CCamSettingsModel::ResetUserSceneL")) |
|
170 } |
|
171 |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CCamSettingsModel::IntegerSettingValue |
|
176 // Returns the current integer value for the specified setting |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 TInt |
|
180 CCamSettingsModel::IntegerSettingValue( TInt aSettingItem ) const |
|
181 { |
|
182 PRINT2( _L("Camera => CCamSettingsModel::IntegerSettingValue, id:%d [%s]"), |
|
183 aSettingItem, |
|
184 KCamSettingItemNames[aSettingItem] ); |
|
185 |
|
186 TInt value = KErrNotFound; |
|
187 // If the requested item is the photo quality value, this must |
|
188 // be filtered based on the current scene. |
|
189 if ( aSettingItem == ECamSettingItemPhotoQuality ) |
|
190 { |
|
191 value = CurrentPhotoQualityValue(); |
|
192 } |
|
193 // If the requested item is the photo size, this must be filtered based on |
|
194 // the current scene |
|
195 else if ( aSettingItem == ECamSettingItemPhotoSize ) |
|
196 { |
|
197 value = CurrentPhotoResolution(); |
|
198 } |
|
199 // If the requested item is the photo compression level, this must |
|
200 // be filtered based on the current scene, and burst mode. |
|
201 else if ( aSettingItem == ECamSettingItemPhotoCompression ) |
|
202 { |
|
203 value = CurrentPhotoCompression(); |
|
204 } |
|
205 else |
|
206 { |
|
207 // If we have previews active, check first if requested |
|
208 // setting is found among them. Settings model must pretend |
|
209 // that the current value is the one set to preview. |
|
210 TInt previewIndex( FindIndex( iSettingPreviews, aSettingItem ) ); |
|
211 if( KErrNotFound != previewIndex ) |
|
212 { |
|
213 PRINT( _L("Camera <> Setting item value in previewed currently!") ); |
|
214 value = iSettingPreviews[previewIndex]->iValueId; |
|
215 |
|
216 if (ECamSettingItemDynamicSelfTimer == aSettingItem) //If the current setting Item is selftimer |
|
217 { |
|
218 TInt settingIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, aSettingItem ); |
|
219 value = iDynamicPhotoIntSettings[settingIndex]->iValueId; //Get the actual selftime setting value but not preview value |
|
220 } |
|
221 } |
|
222 // Otherwise, if setting item is in the dynamic photo settings return it's value. |
|
223 else if( ECamSettingItemDynamicPhotoRangeMax > aSettingItem |
|
224 && ECamSettingItemDynamicPhotoRangeMin < aSettingItem ) |
|
225 { |
|
226 TInt settingIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, aSettingItem ); |
|
227 value = iDynamicPhotoIntSettings[settingIndex]->iValueId; |
|
228 } |
|
229 // Otherwise, if setting item is in the dynamic video settings return it's value. |
|
230 else if( ECamSettingItemDynamicVideoRangeMax > aSettingItem |
|
231 && ECamSettingItemDynamicVideoRangeMin < aSettingItem ) |
|
232 { |
|
233 TInt settingIndex = SearchInSettingsListFor( iDynamicVideoIntSettings, aSettingItem ); |
|
234 value = iDynamicVideoIntSettings[settingIndex]->iValueId; |
|
235 } |
|
236 // Otherwise, if setting item is in the user scene settings return it's value. |
|
237 else if( ECamSettingItemUserSceneRangeMax > aSettingItem |
|
238 && ECamSettingItemUserSceneRangeMin < aSettingItem ) |
|
239 { |
|
240 TInt settingIndex = SearchInSettingsListFor( iUserSceneSettings, aSettingItem ); |
|
241 value = iUserSceneSettings[settingIndex]->iValueId; |
|
242 } |
|
243 // Otherwise, if setting item is in the static video settings return it's value. |
|
244 else if( ECamSettingItemVideoClipLength == aSettingItem ) |
|
245 { |
|
246 // Video clip length workaround |
|
247 // PRINT( _L("Camera <> ECamSettingItemVideoClipLength") ); |
|
248 TInt videoQuality = IntegerSettingValue( ECamSettingItemVideoQuality ); |
|
249 value = iQualityLevels[videoQuality]->VideoLength(); |
|
250 } |
|
251 else |
|
252 { |
|
253 value = iStaticModel->IntegerSettingValue( aSettingItem ); |
|
254 } |
|
255 } |
|
256 |
|
257 PRINT1( _L("Camera <= CCamSettingsModel::IntegerSettingValue, value:%d"), value ); |
|
258 return value; |
|
259 } |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CCamSettingsModel::SceneSettingValue |
|
266 // Returns the setting value for a specific field of a scene |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 TInt |
|
270 CCamSettingsModel::SceneSettingValue( TInt aSceneId, |
|
271 TInt aSceneField ) const |
|
272 { |
|
273 PRINT2( _L("CCamSettingsModel::SceneSettingValue, scene[%s] setting[%s]"), |
|
274 KCamSceneNames[aSceneId], |
|
275 KCamSettingItemNames[aSceneField] ); |
|
276 |
|
277 // If setting item is a scene in the photo scene list |
|
278 TInt sceneIndex = FindSceneInSceneList( aSceneId, iPhotoScenes ); |
|
279 if ( sceneIndex != KErrNotFound ) |
|
280 { |
|
281 // Search for the field in the scene's field list. |
|
282 const RPointerArray<TIntSetting>& sceneSettings = |
|
283 iPhotoScenes[sceneIndex]->iSettings; |
|
284 TInt fieldCount = sceneSettings.Count(); |
|
285 for ( TInt i = 0; i < fieldCount; ++i ) |
|
286 { |
|
287 if ( sceneSettings[i]->iItemId == aSceneField ) |
|
288 { |
|
289 return sceneSettings[i]->iValueId; |
|
290 } |
|
291 } |
|
292 } |
|
293 |
|
294 // Otherwise if setting item is a scene in the video scene list |
|
295 sceneIndex = FindSceneInSceneList( aSceneId, iVideoScenes ); |
|
296 if ( sceneIndex != KErrNotFound ) |
|
297 { |
|
298 // Search for the field in the scene's field list. |
|
299 const RPointerArray<TIntSetting>& sceneSettings = |
|
300 iVideoScenes[sceneIndex]->iSettings; |
|
301 TInt fieldCount = sceneSettings.Count(); |
|
302 for ( TInt i = 0; i < fieldCount; ++i ) |
|
303 { |
|
304 if ( sceneSettings[i]->iItemId == aSceneField ) |
|
305 { |
|
306 return sceneSettings[i]->iValueId; |
|
307 } |
|
308 } |
|
309 } |
|
310 |
|
311 else |
|
312 { |
|
313 PRINT( _L("Camera => CCamSettingsModel::ECamPanicUnknownSettingItem 3" )) |
|
314 CamPanic( ECamPanicUnknownSettingItem ); |
|
315 } |
|
316 |
|
317 return sceneIndex; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // CCamSettingsModel::SetIntegerSettingValueL |
|
322 // Sets a new integer value for the specified setting |
|
323 // --------------------------------------------------------------------------- |
|
324 // |
|
325 void |
|
326 CCamSettingsModel::SetIntegerSettingValueL( TInt aSettingItem, |
|
327 TInt aSettingValue ) |
|
328 { |
|
329 PRINT ( _L("Camera => CCamSettingsModel::SetIntegerSettingValueL") ); |
|
330 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEnv->AppUi() ); |
|
331 TCamSettingItemIds settingId( |
|
332 static_cast<TCamSettingItemIds>(aSettingItem) ); |
|
333 |
|
334 PRINT2( _L("Camera <> Setting item[%s] value:%d"), KCamSettingItemNames[settingId], aSettingValue ); |
|
335 |
|
336 // ------------------------------------------------------- |
|
337 // Dynamic image settings |
|
338 if( ECamSettingItemDynamicPhotoRangeMin < settingId |
|
339 && ECamSettingItemDynamicPhotoRangeMax > settingId ) |
|
340 { |
|
341 TInt settingIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
342 settingId ); |
|
343 iDynamicPhotoIntSettings[settingIndex]->iValueId = aSettingValue; |
|
344 |
|
345 // Changing scene |
|
346 if ( ECamSettingItemDynamicPhotoScene == settingId ) |
|
347 { |
|
348 if ( ECamActiveCameraNone != appUi->ActiveCamera() || ( ECamActiveCameraNone == appUi->ActiveCamera() && ECamSceneAuto == aSettingValue ) ) |
|
349 { |
|
350 PhotoSceneHasChangedL( aSettingValue ); |
|
351 } |
|
352 } |
|
353 } |
|
354 // ------------------------------------------------------- |
|
355 // Dynamic video settings |
|
356 else if( ECamSettingItemDynamicVideoRangeMin < settingId |
|
357 && ECamSettingItemDynamicVideoRangeMax > settingId ) |
|
358 { |
|
359 TInt settingIndex = SearchInSettingsListFor( iDynamicVideoIntSettings, |
|
360 settingId ); |
|
361 iDynamicVideoIntSettings[settingIndex]->iValueId = aSettingValue; |
|
362 if ( settingId == ECamSettingItemDynamicVideoScene ) |
|
363 { |
|
364 VideoSceneHasChangedL( aSettingValue ); |
|
365 } |
|
366 } |
|
367 // ------------------------------------------------------- |
|
368 // User scene settings |
|
369 else if( ECamSettingItemUserSceneRangeMin < settingId |
|
370 && ECamSettingItemUserSceneRangeMax > settingId ) |
|
371 { |
|
372 TBool userSceneModeSettingChanged = EFalse; |
|
373 // If the based-on scene has changed |
|
374 if ( settingId == ECamSettingItemUserSceneBasedOnScene ) |
|
375 { |
|
376 TInt scene = IntegerSettingValue( ECamSettingItemDynamicPhotoScene ); |
|
377 // If current scene is user scene |
|
378 if ( ECamSceneUser == scene ) |
|
379 { |
|
380 // Handle other changes to the settings required by the change in scene. |
|
381 UserSceneHasChangedL( aSettingValue, ETrue ); |
|
382 } |
|
383 // Otherwise the user scene hasn't been selected as the active scene |
|
384 // - the change option has just been selected in the scene setting list |
|
385 else |
|
386 { |
|
387 // just handle a change in the scene |
|
388 UserSceneHasChangedL( aSettingValue, EFalse ); |
|
389 } |
|
390 userSceneModeSettingChanged = ETrue; |
|
391 } |
|
392 // Writing values to CenRep for all the settings. |
|
393 TInt settingIndex = SearchInSettingsListFor( iUserSceneSettings, settingId ); |
|
394 iUserSceneSettings[settingIndex]->iValueId = aSettingValue; |
|
395 SaveStaticSettingL( settingId ); |
|
396 |
|
397 // If there is only one setting changed other than scene mode setting |
|
398 // and if the Dynamic Scene mode is "User Scene" we update the new setting |
|
399 // value to the camera dynamic settings |
|
400 if ( !userSceneModeSettingChanged ) |
|
401 { |
|
402 TInt scene = IntegerSettingValue( ECamSettingItemDynamicPhotoScene ); |
|
403 // If user scene is the currently active photo scene then activate the |
|
404 // new user scene settings. |
|
405 if ( ECamSceneUser == scene ) |
|
406 { |
|
407 CopyUserSceneSettingToCaptureSettingL( settingId ); |
|
408 } |
|
409 } |
|
410 |
|
411 } |
|
412 // ------------------------------------------------------- |
|
413 else |
|
414 { |
|
415 // use the static settings model |
|
416 iStaticModel->SetIntegerSettingValueL( aSettingItem, aSettingValue ); |
|
417 } |
|
418 // ------------------------------------------------------- |
|
419 |
|
420 NotifyObservers( settingId, aSettingValue ); |
|
421 |
|
422 PRINT ( _L("Camera <= CCamSettingsModel::SetIntegerSettingValueL") ); |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CCamSettingsModel::SetTextSettingValueL |
|
428 // Sets a new text value for the specified setting |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 void CCamSettingsModel::SetTextSettingValueL( TInt aSettingItem, |
|
432 const TDesC& aSettingValue ) |
|
433 { |
|
434 iStaticModel->SetTextSettingValueL( aSettingItem, aSettingValue ); |
|
435 NotifyObservers( (TCamSettingItemIds)aSettingItem, aSettingValue ); |
|
436 } |
|
437 |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // CCamSettingsModel::TextSettingValue |
|
441 // Returns the current text value for the specified setting |
|
442 // --------------------------------------------------------------------------- |
|
443 // |
|
444 TPtrC |
|
445 CCamSettingsModel::TextSettingValue( TInt aSettingItem ) const |
|
446 { |
|
447 return iStaticModel->TextSettingValue( aSettingItem ); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 // CCamSettingsModel::SettingValueEnabled |
|
452 // Returns ETrue if the setting value is currently enabled |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 TBool CCamSettingsModel::SettingValueEnabled( TInt aSettingItem, |
|
456 TInt aSettingValue ) const |
|
457 { |
|
458 TCamImageQualitySetting maxPhoto = static_cast<TCamImageQualitySetting>( iPhotoQualityLevels[iPhotoQualityLevels.Count() - 1].iPhotoResolution ); |
|
459 // If the setting value is maximum photo size, and the current |
|
460 // scene is sports, then this setting value is disabled |
|
461 if ( ( aSettingItem == ECamSettingItemPhotoQuality ) && |
|
462 ( aSettingValue == maxPhoto ) ) |
|
463 { |
|
464 // If the current scene is sports, disable the option |
|
465 TCamSceneId scene = static_cast< TCamSceneId > |
|
466 ( IntegerSettingValue( ECamSettingItemDynamicPhotoScene ) ); |
|
467 if ( scene == ECamSceneSports ) |
|
468 { |
|
469 return EFalse; |
|
470 } |
|
471 // Otherwise, if the current scene is the user scene and |
|
472 // it is based on the 'Sports' scene then disable the option. |
|
473 else if ( scene == ECamSceneUser ) |
|
474 { |
|
475 // ...Get the based on scene. |
|
476 TCamSceneId baseScene = static_cast< TCamSceneId > |
|
477 ( IntegerSettingValue( ECamSettingItemUserSceneBasedOnScene ) ); |
|
478 if ( baseScene == ECamSceneSports ) |
|
479 { |
|
480 return EFalse; |
|
481 } |
|
482 } |
|
483 else |
|
484 { |
|
485 // Otherwise, the option is enabled |
|
486 return ETrue; |
|
487 } |
|
488 } |
|
489 // The high quality video setting is not supported if |
|
490 // the second camera is enabled |
|
491 else if ( aSettingItem == ECamSettingItemVideoQuality && |
|
492 aSettingValue == ECamVideoQualityHigh && |
|
493 static_cast<CCamAppUiBase*>( |
|
494 iEnv->AppUi() )->IsSecondCameraEnabled() ) |
|
495 { |
|
496 return EFalse; |
|
497 } |
|
498 // All other setting item values are allowed |
|
499 else |
|
500 { |
|
501 return ETrue; |
|
502 } |
|
503 |
|
504 return ETrue; |
|
505 } |
|
506 |
|
507 |
|
508 |
|
509 // --------------------------------------------------------------------------- |
|
510 // |
|
511 // --------------------------------------------------------------------------- |
|
512 // |
|
513 void |
|
514 CCamSettingsModel |
|
515 ::AttachObserverL( const MCamSettingsModelObserver* aObserver ) |
|
516 { |
|
517 if( aObserver ) |
|
518 { |
|
519 TInt index = iObservers.Find( aObserver ); |
|
520 if( KErrNotFound == index ) |
|
521 { |
|
522 iObservers.AppendL( aObserver ); |
|
523 } |
|
524 } |
|
525 } |
|
526 |
|
527 |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 // --------------------------------------------------------------------------- |
|
531 // |
|
532 void |
|
533 CCamSettingsModel |
|
534 ::DetachObserver( const MCamSettingsModelObserver* aObserver ) |
|
535 { |
|
536 if( aObserver ) |
|
537 { |
|
538 TInt index = iObservers.Find( aObserver ); |
|
539 if( KErrNotFound != index ) |
|
540 { |
|
541 iObservers.Remove( index ); |
|
542 } |
|
543 } |
|
544 } |
|
545 |
|
546 |
|
547 |
|
548 // --------------------------------------------------------------------------- |
|
549 // CCamSettingsModel::LoadSettingsL |
|
550 // Loads the settings from shared data, or if unable to from the resource file. |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 void |
|
554 CCamSettingsModel::LoadSettingsL() |
|
555 { |
|
556 PRINT( _L("Camera => CCamSettingsModel::LoadSettingsL")) |
|
557 // Remove any previously loaded values. |
|
558 UnloadSettings(); |
|
559 |
|
560 PRINT( _L("Camera => CCamSettingsModel::LoadSettingsL B")) |
|
561 LoadDynamicSettingsL( R_CAM_PHOTO_DYNAMIC_SETTINGS_DATA, |
|
562 iDynamicPhotoIntSettings, |
|
563 iDynamicPhotoIntDefaults ); |
|
564 |
|
565 PRINT( _L("Camera => CCamSettingsModel::LoadSettingsL C")) |
|
566 LoadDynamicSettingsL( R_CAM_VIDEO_DYNAMIC_SETTINGS_DATA, |
|
567 iDynamicVideoIntSettings, |
|
568 iDynamicVideoIntDefaults ); |
|
569 |
|
570 PRINT( _L("Camera => CCamSettingsModel::LoadSettingsL D")) |
|
571 // Load image scene data |
|
572 LoadSceneDataL(); |
|
573 |
|
574 // Load video scene data |
|
575 LoadSceneDataL( EFalse ); |
|
576 |
|
577 PRINT( _L("Camera => CCamSettingsModel::LoadSettingsL E")) |
|
578 //LoadScenesDataL( R_CAM_VIDEO_SCENES_DATA, iVideoScenes ); |
|
579 |
|
580 PRINT( _L("Camera <= CCamSettingsModel::LoadSettingsL")) |
|
581 } |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 // --------------------------------------------------------------------------- |
|
587 // DynamicSettingDefaultValue |
|
588 // |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 TInt |
|
592 CCamSettingsModel::DynamicSettingDefaultValue( TInt aSettingId ) const |
|
593 { |
|
594 TInt value = KErrNotFound; |
|
595 |
|
596 TInt index = SearchInSettingsListFor( iDynamicPhotoIntSettings, aSettingId ); |
|
597 if( KErrNotFound != index ) |
|
598 { |
|
599 value = iDynamicPhotoIntDefaults[index]; |
|
600 } |
|
601 index = SearchInSettingsListFor( iDynamicVideoIntSettings, aSettingId ); |
|
602 if( KErrNotFound != index ) |
|
603 { |
|
604 value = iDynamicVideoIntDefaults[index]; |
|
605 } |
|
606 |
|
607 return value; |
|
608 } |
|
609 |
|
610 // --------------------------------------------------------------------------- |
|
611 // CCamSettingsModel::SetDynamicSettingsToDefaults |
|
612 // Sets all dynamic settings to their defaults. |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 void CCamSettingsModel::SetDynamicSettingsToDefaults() |
|
616 { |
|
617 // Set photo dynamic settings to their defaults. |
|
618 TInt i; |
|
619 TInt settingsListCount = iDynamicPhotoIntSettings.Count(); |
|
620 for ( i = 0; i < settingsListCount; ++i ) |
|
621 { |
|
622 iDynamicPhotoIntSettings[i]->iValueId = iDynamicPhotoIntDefaults[i]; |
|
623 } |
|
624 // Set video dynamic settings to their defaults. |
|
625 settingsListCount = iDynamicVideoIntSettings.Count(); |
|
626 for ( i = 0; i < settingsListCount; ++i ) |
|
627 { |
|
628 iDynamicVideoIntSettings[i]->iValueId = iDynamicVideoIntDefaults[i]; |
|
629 } |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // CCamSettingsModel::SetDynamicSettingsToDefault |
|
634 // Sets a dynamic setting to its default. |
|
635 // --------------------------------------------------------------------------- |
|
636 // |
|
637 void CCamSettingsModel::SetDynamicSettingToDefault( TInt aSettingItem ) |
|
638 { |
|
639 // Set photo dynamic settings to their defaults. |
|
640 TInt i; |
|
641 TBool found = EFalse; |
|
642 TInt settingsListCount = iDynamicPhotoIntSettings.Count(); |
|
643 for ( i = 0; i < settingsListCount && !found; ++i ) |
|
644 { |
|
645 if ( aSettingItem == iDynamicPhotoIntSettings[i]->iItemId ) |
|
646 { |
|
647 iDynamicPhotoIntSettings[i]->iValueId = iDynamicPhotoIntDefaults[i]; |
|
648 found = ETrue; |
|
649 } |
|
650 } |
|
651 // Set video dynamic settings to their defaults. |
|
652 settingsListCount = iDynamicVideoIntSettings.Count(); |
|
653 for ( i = 0; i < settingsListCount && !found; ++i ) |
|
654 { |
|
655 if ( aSettingItem == iDynamicVideoIntSettings[i]->iItemId ) |
|
656 { |
|
657 iDynamicVideoIntSettings[i]->iValueId = iDynamicVideoIntDefaults[i]; |
|
658 found = ETrue; |
|
659 } |
|
660 } |
|
661 |
|
662 // NB no error is reported is it's not found |
|
663 } |
|
664 |
|
665 |
|
666 // --------------------------------------------------------------------------- |
|
667 // virtual SetDynamicSettingToSceneDefaultL |
|
668 // |
|
669 // Sets a dynamic setting to scene default. |
|
670 // --------------------------------------------------------------------------- |
|
671 // |
|
672 TInt |
|
673 CCamSettingsModel::SetDynamicSettingToSceneDefaultL( TInt aSceneId, |
|
674 TInt aSceneField, |
|
675 TInt aSettingId, |
|
676 TBool aVideoScene ) |
|
677 { |
|
678 PRINT( _L("Camera => CCamSettingsModel::SetDynamicSettingToSceneDefault") ); |
|
679 |
|
680 RPointerArray<TIntSetting>* sceneSettings = NULL; |
|
681 TInt sceneIndex = KErrNotFound; |
|
682 |
|
683 if( !aVideoScene ) |
|
684 { |
|
685 sceneIndex = FindSceneInSceneList( aSceneId, iPhotoScenes ); |
|
686 if( KErrNotFound != sceneIndex ) |
|
687 { |
|
688 sceneSettings = &(iPhotoScenes[sceneIndex]->iSettings); |
|
689 } |
|
690 } |
|
691 else |
|
692 { |
|
693 sceneIndex = FindSceneInSceneList( aSceneId, iVideoScenes ); |
|
694 if( KErrNotFound != sceneIndex ) |
|
695 { |
|
696 sceneSettings = &(iVideoScenes[sceneIndex]->iSettings); |
|
697 } |
|
698 } |
|
699 |
|
700 TInt settingIndex = KErrNotFound; |
|
701 if( sceneSettings ) |
|
702 { |
|
703 settingIndex = SearchInSettingsListFor( *sceneSettings, aSceneField ); |
|
704 if( settingIndex != KErrNotFound ) |
|
705 { |
|
706 SetIntegerSettingValueL( aSettingId, |
|
707 (*sceneSettings)[settingIndex]->iValueId ); |
|
708 } |
|
709 } |
|
710 |
|
711 PRINT( _L("Camera <= CCamSettingsModel::SetDynamicSettingToSceneDefault") ); |
|
712 return settingIndex; |
|
713 } |
|
714 |
|
715 |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // CCamSettingsModel::LoadStaticSettingsL |
|
719 // Loads the static settings from shared data. Required to update |
|
720 // the settings whenever get foreground event, incase of external |
|
721 // changes to the settings. |
|
722 // Note that static settings cannot be loaded until the AppUi has been created, |
|
723 // as which settings to use is dependent on if app is embedded or not. |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 void CCamSettingsModel::LoadStaticSettingsL( TBool aIsEmbedded ) |
|
727 { |
|
728 PRINT(_L("Camera => CCamSettingsModel::LoadStaticSettingsL" )) |
|
729 iEmbedded = aIsEmbedded; |
|
730 |
|
731 // The model needs to register as an observer of changes in burst mode |
|
732 // activation, as burst mode limits some settings values. |
|
733 // The model registers with the AppUi which is created after the model. |
|
734 // Registration is done here so we can guarantee that the AppUi has |
|
735 // been created. |
|
736 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*> |
|
737 ( iEnv->AppUi() ); |
|
738 appUi->AddBurstModeObserverL( this ); |
|
739 |
|
740 // Free all memory currently used by the static settings. |
|
741 UnloadStaticSettings(); |
|
742 |
|
743 iStaticModel->ReadFromCenRepL( |
|
744 static_cast<TInt>( ECamSettingItemUserSceneRangeMin ), |
|
745 static_cast<TInt>( ECamSettingItemUserSceneRangeMax ), |
|
746 iUserSceneSettings |
|
747 ); |
|
748 iStaticModel->LoadStaticSettingsL( aIsEmbedded ); |
|
749 |
|
750 PRINT(_L("Camera <= CCamSettingsModel::LoadStaticSettingsL" )) |
|
751 |
|
752 } |
|
753 |
|
754 |
|
755 // --------------------------------------------------------------------------- |
|
756 // CCamSettingsModel::SaveSettingsL |
|
757 // Saves the static settings to the shared data ini file |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void CCamSettingsModel::SaveSettingsL() |
|
761 { |
|
762 // This method is removed as we save to the CenRep whenever some setting |
|
763 // is changed directly .. refer to SaveStaticSettingsL method |
|
764 } |
|
765 |
|
766 |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void |
|
772 CCamSettingsModel::SaveStaticSettingL( TCamSettingItemIds aSettingId ) |
|
773 { |
|
774 PRINT1( _L("Camera => CCamSettingsModel::SaveStaticSettingL, setting:[%s]"), |
|
775 KCamSettingItemNames[aSettingId] ); |
|
776 TBool callStaticModel = ETrue; |
|
777 |
|
778 { |
|
779 // All the User Specific Settings are saved here in the CenRep |
|
780 // and the remaining static settings are handled in the static model |
|
781 RPointerArray<TIntSetting>* settingArray = |
|
782 MapSettingItem2SettingsList( aSettingId ); |
|
783 |
|
784 if( settingArray == &iUserSceneSettings ) |
|
785 { |
|
786 callStaticModel = EFalse; |
|
787 TUint32 crKey = CCamStaticSettingsModel::MapSettingItem2CRKey( aSettingId, iEmbedded ); |
|
788 iStaticModel->SaveCenRepItemL( aSettingId, crKey, *settingArray ); |
|
789 } |
|
790 } |
|
791 if ( callStaticModel ) |
|
792 { |
|
793 iStaticModel->SaveStaticSettingL( aSettingId ); |
|
794 } |
|
795 PRINT( _L("Camera <= CCamSettingsModel::SaveStaticSettingL") ); |
|
796 } |
|
797 |
|
798 |
|
799 // --------------------------------------------------------------------------- |
|
800 // |
|
801 // --------------------------------------------------------------------------- |
|
802 // |
|
803 RPointerArray<TIntSetting>* |
|
804 CCamSettingsModel::MapSettingItem2SettingsList( TCamSettingItemIds aSettingId ) |
|
805 { |
|
806 PRINT( _L("Camera => CCamSettingsModel::MapSettingItem2SettingsList") ); |
|
807 |
|
808 RPointerArray<TIntSetting>* array( NULL ); |
|
809 |
|
810 if( ECamSettingItemUserSceneRangeMin < aSettingId |
|
811 && ECamSettingItemUserSceneRangeMax > aSettingId ) |
|
812 { |
|
813 array = &iUserSceneSettings; |
|
814 } |
|
815 else if( ECamSettingItemDynamicPhotoRangeMin < aSettingId |
|
816 && ECamSettingItemDynamicPhotoRangeMax > aSettingId ) |
|
817 { |
|
818 array = &iDynamicPhotoIntSettings; |
|
819 } |
|
820 else if( ECamSettingItemDynamicVideoRangeMin < aSettingId |
|
821 && ECamSettingItemDynamicVideoRangeMax > aSettingId ) |
|
822 { |
|
823 array = &iDynamicVideoIntSettings; |
|
824 } |
|
825 else |
|
826 { |
|
827 array = iStaticModel->MapSettingItem2SettingsList( aSettingId ); |
|
828 } |
|
829 |
|
830 PRINT( _L("Camera <= CCamSettingsModel::MapSettingItem2SettingsList") ); |
|
831 return array; |
|
832 } |
|
833 |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // CCamSettingsModel::~CCamSettingsModel |
|
837 // Destructor |
|
838 // --------------------------------------------------------------------------- |
|
839 // |
|
840 CCamSettingsModel::~CCamSettingsModel() |
|
841 { |
|
842 PRINT( _L("Camera => ~CCamSettingsModel") ); |
|
843 |
|
844 UnLoadResources(); |
|
845 |
|
846 iObservers.Reset(); |
|
847 iObservers.Close(); |
|
848 |
|
849 iSettingPreviews.ResetAndDestroy(); |
|
850 iSettingPreviews.Close(); |
|
851 |
|
852 |
|
853 iUserSceneSettings.ResetAndDestroy(); |
|
854 iUserSceneSettings.Close(); |
|
855 |
|
856 iUserSceneSettingsBackup.ResetAndDestroy(); |
|
857 iUserSceneSettingsBackup.Close(); |
|
858 |
|
859 iDynamicPhotoIntSettings.ResetAndDestroy(); |
|
860 iDynamicPhotoIntSettings.Close(); |
|
861 |
|
862 iDynamicPhotoIntSettingsBackup.ResetAndDestroy(); |
|
863 iDynamicPhotoIntSettingsBackup.Close(); |
|
864 |
|
865 iDynamicPhotoIntDefaults.Close(); |
|
866 |
|
867 iDynamicVideoIntSettings.ResetAndDestroy(); |
|
868 iDynamicVideoIntSettings.Close(); |
|
869 |
|
870 iDynamicVideoIntSettingsBackup.ResetAndDestroy(); |
|
871 iDynamicVideoIntSettingsBackup.Close(); |
|
872 |
|
873 iDynamicVideoIntDefaults.Close(); |
|
874 |
|
875 iPhotoScenes.ResetAndDestroy(); |
|
876 iPhotoScenes.Close(); |
|
877 |
|
878 iVideoScenes.ResetAndDestroy(); |
|
879 iVideoScenes.Close(); |
|
880 |
|
881 iQualityLevels.ResetAndDestroy(); |
|
882 iQualityLevels.Close(); |
|
883 |
|
884 iVideoResolutions.Close(); |
|
885 iPhotoQualityLevels.Close(); |
|
886 iPhotoResolutions.Close(); |
|
887 |
|
888 if ( iStaticModel ) |
|
889 { |
|
890 delete iStaticModel; |
|
891 iStaticModel = NULL; |
|
892 } |
|
893 |
|
894 PRINT( _L("Camera <= ~CCamSettingsModel") ); |
|
895 } |
|
896 |
|
897 // --------------------------------------------------------------------------- |
|
898 // CCamSettingsModel::CCamSettingsModel |
|
899 // C++ constructor |
|
900 // --------------------------------------------------------------------------- |
|
901 // |
|
902 CCamSettingsModel::CCamSettingsModel( CCamConfiguration& aConfiguration ) |
|
903 : iDynamicPhotoIntDefaults( KDynamicArrayGranularity ), |
|
904 iDynamicVideoIntDefaults( KDynamicArrayGranularity ), |
|
905 iEngineReadyForVideoPrepare( ETrue ), |
|
906 iConfiguration( aConfiguration ) |
|
907 { |
|
908 PRINT( _L("Camera => CCamSettingsModel::CCamSettingsModel") ); |
|
909 |
|
910 // set up secondary camera defaults |
|
911 // these values are not stored in the shared data file because |
|
912 // they do not persist when the camera is changed or the app is closed |
|
913 |
|
914 iSecondaryCameraSettings.iVideoQuality |
|
915 = iConfiguration.SecondaryCameraVideoQuality(); |
|
916 iSecondaryCameraSettings.iPhotoQuality |
|
917 = iConfiguration.SecondaryCameraImageQuality(); |
|
918 |
|
919 // Check that configuration can provide us secondary camera qualities |
|
920 // If either of them is unavailable, all we can do is panic |
|
921 PRINT( _L("Camera <> Checking secondary camera qualities") ); |
|
922 __ASSERT_ALWAYS( iSecondaryCameraSettings.iVideoQuality > 0, |
|
923 CamPanic( ECamPanicSecondaryQualityMissing ) ); |
|
924 |
|
925 __ASSERT_ALWAYS( iSecondaryCameraSettings.iPhotoQuality > 0, |
|
926 CamPanic( ECamPanicSecondaryQualityMissing ) ); |
|
927 |
|
928 // Check that configuration can provide us a MMS quality. |
|
929 // If not available, all we can do is panic. MMS quality is |
|
930 // needed in embedded mode. |
|
931 PRINT( _L("Camera <> Checking MMS quality") ); |
|
932 __ASSERT_ALWAYS( iConfiguration.MmsImageQuality() > 0, |
|
933 CamPanic( ECamPanicMMSQualityMissing ) ); |
|
934 |
|
935 |
|
936 PRINT( _L("Camera <= CCamSettingsModel::CCamSettingsModel") ); |
|
937 } |
|
938 |
|
939 |
|
940 |
|
941 // --------------------------------------------------------------------------- |
|
942 // CCamSettingsModel::ConstructL |
|
943 // Symbian OS 2nd phase constructor |
|
944 // --------------------------------------------------------------------------- |
|
945 // |
|
946 void CCamSettingsModel::ConstructL() |
|
947 { |
|
948 PRINT( _L("Camera => CCamSettingsModel::ConstructL")) |
|
949 // Create reference to the CEikonEnv object, since it is used alot. |
|
950 iEnv = CEikonEnv::Static(); |
|
951 |
|
952 LoadResourcesL(); |
|
953 |
|
954 iStaticModel = CCamStaticSettingsModel::NewL( iConfiguration ); |
|
955 |
|
956 iUiConfigManager = iStaticModel->UiConfigManagerPtr(); |
|
957 |
|
958 if ( !iUiConfigManager )CamPanic( ECamPanicNullPointer ); |
|
959 |
|
960 PRINT( _L("Camera => CCamSettingsModel::ConstructL create respository")) |
|
961 |
|
962 // Load settings. |
|
963 LoadSettingsL(); |
|
964 |
|
965 // Load the variant flags from the ini file |
|
966 ReadVariantFlagsL(); |
|
967 |
|
968 // Load flag that specifies whether the engine should be updated with |
|
969 // settings after an engine Prepare..() call. |
|
970 // Create resource reader for reading photo static settings |
|
971 TResourceReader reader; |
|
972 iEnv->CreateResourceReaderLC( reader, R_CAM_ENGINE_UPDATE ); |
|
973 iUpdateAfterPrepare = reader.ReadInt16(); |
|
974 // Pop resource reader. |
|
975 CleanupStack::PopAndDestroy(); |
|
976 |
|
977 // read in video quality levels |
|
978 TInt i; |
|
979 |
|
980 const TInt nVidQualities( iConfiguration.NumVideoQualities() ); |
|
981 for ( i=0; i < nVidQualities; i++ ) |
|
982 { |
|
983 TVideoQualitySettings set = iConfiguration.VideoQuality( i ); |
|
984 CCamVideoQualityLevel* lev = CCamVideoQualityLevel::NewL( set ); |
|
985 CleanupStack::PushL( lev ); |
|
986 User::LeaveIfError( iQualityLevels.Append( lev ) ); |
|
987 CleanupStack::Pop( lev ); |
|
988 } |
|
989 |
|
990 // read in (supported) video resolutions |
|
991 TResourceReader videoResReader; |
|
992 iEnv->CreateResourceReaderLC( videoResReader, R_CAM_VIDEO_RESOLUTION_ARRAY ); |
|
993 |
|
994 // get array of supported values |
|
995 RArray<TInt> supportedVideoRes; |
|
996 CleanupClosePushL( supportedVideoRes ); |
|
997 iConfiguration.GetPsiIntArrayL( ECamPsiSupportedVideoResolutions, supportedVideoRes ); |
|
998 |
|
999 TInt numLevels = videoResReader.ReadInt16(); |
|
1000 |
|
1001 for( i = 0; i < numLevels; i++ ) |
|
1002 { |
|
1003 TSize videoRes; |
|
1004 videoRes.iWidth = videoResReader.ReadInt16(); |
|
1005 videoRes.iHeight = videoResReader.ReadInt16(); |
|
1006 |
|
1007 User::LeaveIfError( iVideoResolutions.Append( videoRes ) ); |
|
1008 } |
|
1009 |
|
1010 // Close array of support vid resolutions |
|
1011 CleanupStack::PopAndDestroy( &supportedVideoRes ); |
|
1012 |
|
1013 // Pop resource reader. |
|
1014 CleanupStack::PopAndDestroy(); |
|
1015 |
|
1016 |
|
1017 const TInt numQualities( iConfiguration.NumImageQualities() ); |
|
1018 for( i=0; i<numQualities; i++ ) |
|
1019 { |
|
1020 User::LeaveIfError( |
|
1021 iPhotoQualityLevels.Append( iConfiguration.ImageQuality( i ) ) ); |
|
1022 } |
|
1023 |
|
1024 // read in photo resolutions |
|
1025 TResourceReader photoResReader; |
|
1026 iEnv->CreateResourceReaderLC( photoResReader, R_CAM_PHOTO_RESOLUTION_ARRAY ); |
|
1027 numLevels = photoResReader.ReadInt16(); |
|
1028 |
|
1029 // get array of supported values |
|
1030 RArray<TInt> supportedStillRes; |
|
1031 CleanupClosePushL( supportedStillRes ); |
|
1032 |
|
1033 iConfiguration.GetPsiIntArrayL( ECamPsiSupportedStillResolutions, supportedStillRes ); |
|
1034 |
|
1035 for( i = 0; i < numLevels; i++ ) |
|
1036 { |
|
1037 TSize photoRes; |
|
1038 photoRes.iWidth = photoResReader.ReadInt16(); |
|
1039 photoRes.iHeight = photoResReader.ReadInt16(); |
|
1040 |
|
1041 User::LeaveIfError( iPhotoResolutions.Append( photoRes ) ); |
|
1042 |
|
1043 } |
|
1044 |
|
1045 iPreviousFaceTrack = ECamSettOn; |
|
1046 iPreviousSceneMode = ECamSceneAuto; |
|
1047 // Close array of support photo resolutions |
|
1048 CleanupStack::PopAndDestroy( &supportedStillRes ); |
|
1049 |
|
1050 // Pop resource reader. |
|
1051 CleanupStack::PopAndDestroy(); |
|
1052 |
|
1053 PRINT( _L("Camera <= CCamSettingsModel::ConstructL")) |
|
1054 } |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 // --------------------------------------------------------------------------- |
|
1060 // NotifyObservers |
|
1061 // |
|
1062 // Notify setting model observers, that a setting item value has changed. |
|
1063 // Overload for integer setting items. |
|
1064 // --------------------------------------------------------------------------- |
|
1065 // |
|
1066 void |
|
1067 CCamSettingsModel::NotifyObservers( TCamSettingItemIds aSettingId, |
|
1068 TInt aSettingValue ) |
|
1069 { |
|
1070 PRINT1( _L("Camera => CCamSettingsModel::NotifyObservers, observers:%d"), iObservers.Count() ); |
|
1071 for( TInt i = 0; i < iObservers.Count(); i++ ) |
|
1072 { |
|
1073 TRAP_IGNORE( iObservers[i]->IntSettingChangedL( aSettingId, |
|
1074 aSettingValue ) ); |
|
1075 } |
|
1076 PRINT ( _L("Camera <= CCamSettingsModel::NotifyObservers") ); |
|
1077 } |
|
1078 |
|
1079 // --------------------------------------------------------------------------- |
|
1080 // NotifyObservers |
|
1081 // |
|
1082 // Notify setting model observers, that a setting item value has changed. |
|
1083 // Overload for text setting items. |
|
1084 // --------------------------------------------------------------------------- |
|
1085 // |
|
1086 void |
|
1087 CCamSettingsModel::NotifyObservers( TCamSettingItemIds aSettingId, |
|
1088 const TDesC& aSettingValue ) |
|
1089 { |
|
1090 for( TInt i = 0; i < iObservers.Count(); i++ ) |
|
1091 { |
|
1092 TRAP_IGNORE( iObservers[i]->TextSettingChangedL( aSettingId, |
|
1093 aSettingValue ) ); |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // ReadVariantFlagsL |
|
1100 // |
|
1101 // Read Central Repository key values in KCRUidCameraappVariant repository. |
|
1102 // --------------------------------------------------------------------------- |
|
1103 // |
|
1104 void |
|
1105 CCamSettingsModel::ReadVariantFlagsL() |
|
1106 { |
|
1107 TInt crValue( 0 ); |
|
1108 CRepository* cr = CRepository::NewLC( KCRUidCameraappVariant ); |
|
1109 |
|
1110 // Get variant info general flags |
|
1111 User::LeaveIfError( cr->Get( KCamCrVariantFlags, crValue ) ); |
|
1112 iVariantInfo.iFlags = crValue; |
|
1113 |
|
1114 // Get 'time lapse enabled' flag |
|
1115 User::LeaveIfError( cr->Get( KCamCrTimeLapseSupport, crValue ) ); |
|
1116 |
|
1117 iVariantInfo.iTimeLapseSupport = (KCamCrTimeLapseIsSupported == crValue) |
|
1118 ? ECamSupportOn |
|
1119 : ECamSupportOff; |
|
1120 |
|
1121 // Get 'app always running' flag |
|
1122 User::LeaveIfError( cr->Get( KCamCrAppAlwaysRunning, crValue ) ); |
|
1123 iVariantInfo.iAlwaysOnSupport = (KCamCrAppAlwaysRunningIsOn == crValue) |
|
1124 ? ECamSupportOn |
|
1125 : ECamSupportOff; |
|
1126 |
|
1127 |
|
1128 // Get Public Release version |
|
1129 User::LeaveIfError( cr->Get( KCamCrVersionMajor, crValue ) ); |
|
1130 iVariantInfo.iVersion.iMajor = (TInt8) crValue; |
|
1131 |
|
1132 User::LeaveIfError( cr->Get( KCamCrVersionMinor, crValue ) ); |
|
1133 iVariantInfo.iVersion.iMinor = (TInt8) crValue; |
|
1134 |
|
1135 User::LeaveIfError( cr->Get( KCamCrBuildNumber, crValue ) ); |
|
1136 iVariantInfo.iVersion.iBuild = (TInt16) crValue; |
|
1137 |
|
1138 CleanupStack::PopAndDestroy( cr ); |
|
1139 } |
|
1140 |
|
1141 |
|
1142 // --------------------------------------------------------------------------- |
|
1143 // CCamSettingsModel::SettingIsForEngine |
|
1144 // Returns whether a particular setting is an engine setting, or not. |
|
1145 // --------------------------------------------------------------------------- |
|
1146 // |
|
1147 TBool CCamSettingsModel::SettingIsForEngine( TInt aSettingItem ) |
|
1148 { |
|
1149 if ( ( aSettingItem == ECamSettingItemPhotoQuality ) || |
|
1150 ( aSettingItem == ECamSettingItemVideoAudioRec ) || |
|
1151 ( aSettingItem == ECamSettingItemVideoResolution ) || |
|
1152 ( aSettingItem == ECamSettingItemVideoFileType ) || |
|
1153 ( aSettingItem == ECamSettingItemVideoQuality ) ) |
|
1154 { |
|
1155 return ETrue; |
|
1156 } |
|
1157 else |
|
1158 { |
|
1159 return EFalse; |
|
1160 } |
|
1161 } |
|
1162 |
|
1163 |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // CCamSettingsModel::SearchInSettingsListFor |
|
1166 // Searches in a settings list for a particular setting item. |
|
1167 // --------------------------------------------------------------------------- |
|
1168 // |
|
1169 TInt CCamSettingsModel::SearchInSettingsListFor |
|
1170 ( const RPointerArray<TIntSetting>& aSettingsList, TInt aSettingItem ) const |
|
1171 { |
|
1172 TInt count = aSettingsList.Count(); |
|
1173 PRINT2( _L("Camera => CCamSettingsModel::SearchInSettingsListFor item (%d) count (%d)"), aSettingItem, count) |
|
1174 TInt i; |
|
1175 for ( i = 0; i < count; ++i ) |
|
1176 { |
|
1177 if ( aSettingsList[i]->iItemId == aSettingItem ) |
|
1178 { |
|
1179 return i; |
|
1180 } |
|
1181 } |
|
1182 |
|
1183 return KErrNotFound; |
|
1184 } |
|
1185 |
|
1186 // --------------------------------------------------------------------------- |
|
1187 // CCamSettingsModel::FindSceneInSceneList |
|
1188 // Finds a scene in a particular scene list. |
|
1189 // --------------------------------------------------------------------------- |
|
1190 // |
|
1191 TInt CCamSettingsModel::FindSceneInSceneList |
|
1192 ( TInt aSceneItemId, const RPointerArray<TSceneData >& aSceneList ) const |
|
1193 { |
|
1194 TInt count = aSceneList.Count(); |
|
1195 TInt i; |
|
1196 for ( i = 0; i < count; ++i ) |
|
1197 { |
|
1198 if ( aSceneList[i]->iSceneId == aSceneItemId ) |
|
1199 { |
|
1200 return i; |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 return KErrNotFound; |
|
1205 } |
|
1206 |
|
1207 // --------------------------------------------------------------------------- |
|
1208 // CCamSettingsModel::UserSceneHasChangedL |
|
1209 // Handles a change in the value for the user scene setting. |
|
1210 // That is, it updates the rest of the user setings. |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // |
|
1213 void CCamSettingsModel::UserSceneHasChangedL( TInt aSceneId, TBool aActivate ) |
|
1214 { |
|
1215 |
|
1216 // Set the user setup flash setting to that of the new scene. |
|
1217 TInt sceneFlash = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneFlashMode ); |
|
1218 SetIntegerSettingValueL( ECamSettingItemUserSceneFlash, sceneFlash ); |
|
1219 |
|
1220 // Set the user setup whitebalance to that of the new scene |
|
1221 TInt whiteBal = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneAWBMode ); |
|
1222 SetIntegerSettingValueL( ECamSettingItemUserSceneWhitebalance, whiteBal ); |
|
1223 |
|
1224 // Set the user setup sharpness to that of the new scene |
|
1225 TInt sharpness = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneSharpness ); |
|
1226 SetIntegerSettingValueL( ECamSettingItemUserSceneImageSharpness, sharpness ); |
|
1227 |
|
1228 // Set the user setup contrast to that of the new scene |
|
1229 TInt contrast = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneContrast ); |
|
1230 SetIntegerSettingValueL( ECamSettingItemUserSceneContrast, contrast ); |
|
1231 |
|
1232 // Set the scene |
|
1233 TInt settingIndex = SearchInSettingsListFor( iUserSceneSettings, |
|
1234 ECamSettingItemUserSceneBasedOnScene ); |
|
1235 iUserSceneSettings[settingIndex]->iValueId = aSceneId; |
|
1236 |
|
1237 // Save the new values. |
|
1238 SaveSettingsL(); |
|
1239 |
|
1240 if ( aActivate ) |
|
1241 { |
|
1242 // Activate user scene settings. |
|
1243 ActivateUserSceneSettingsL(); |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // CCamSettingsModel::PhotoSceneHasChangedL |
|
1249 // Handles a change in the value for the photo scene setting. |
|
1250 // That is, it updates the rest of the photo dynamic setings. |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CCamSettingsModel::PhotoSceneHasChangedL( TInt aSceneId ) |
|
1254 { |
|
1255 // If the scene has changed to a scene other than the "User" scene |
|
1256 // set capture setup values to defaults and the flash to scene flash. |
|
1257 if ( aSceneId != ECamSceneUser ) |
|
1258 { |
|
1259 // Set all the photo capture setup values to their defaults, except |
|
1260 // for the scene setting. |
|
1261 TInt settingsCount = iDynamicPhotoIntSettings.Count(); |
|
1262 TInt i; |
|
1263 for ( i = 0; i < settingsCount; ++i ) |
|
1264 { |
|
1265 // If the setting item is not the scene change it's value, |
|
1266 // and update the engine |
|
1267 if ( iDynamicPhotoIntSettings[i]->iItemId != ECamSettingItemDynamicPhotoScene ) |
|
1268 { |
|
1269 SetIntegerSettingValueL( iDynamicPhotoIntSettings[i]->iItemId, |
|
1270 iDynamicPhotoIntDefaults[i] ); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 // Set the capture setup flash setting to that of the new scene. |
|
1275 TInt sceneFlash = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneFlashMode ); |
|
1276 SetIntegerSettingValueL( ECamSettingItemDynamicPhotoFlash, sceneFlash ); |
|
1277 |
|
1278 // Set the user setup whitebalance to that of the new scene |
|
1279 TInt whiteBal = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneAWBMode ); |
|
1280 SetIntegerSettingValueL( ECamSettingItemDynamicPhotoWhiteBalance, whiteBal ); |
|
1281 |
|
1282 // Set the user setup sharpness to that of the new scene |
|
1283 TInt sharpness = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneSharpness ); |
|
1284 SetIntegerSettingValueL( ECamSettingItemDynamicPhotoImageSharpness, sharpness ); |
|
1285 |
|
1286 // Set the user setup contrast to that of the new scene |
|
1287 TInt contrast = DefaultSettingValueForScene( aSceneId, ECamSettingItemSceneContrast ); |
|
1288 SetIntegerSettingValueL( ECamSettingItemDynamicPhotoBrightness, contrast ); |
|
1289 |
|
1290 if ( iUiConfigManager->IsFaceTrackingSupported() ) // FT supported |
|
1291 { |
|
1292 if ( ECamSceneScenery == aSceneId || ECamSceneSports == aSceneId ) |
|
1293 { |
|
1294 if ( ECamSceneScenery != iPreviousSceneMode && ECamSceneSports != iPreviousSceneMode ) // <- DATAMAKE |
|
1295 { |
|
1296 iPreviousFaceTrack = TCamSettingsOnOff( IntegerSettingValue( ECamSettingItemFaceTracking ) ); |
|
1297 } |
|
1298 SetIntegerSettingValueL( ECamSettingItemFaceTracking, ECamSettOff ); |
|
1299 } |
|
1300 else if ( ( ECamSceneScenery == iPreviousSceneMode || |
|
1301 ECamSceneSports == iPreviousSceneMode ) && |
|
1302 ( ECamSettOff == TCamSettingsOnOff( IntegerSettingValue( ECamSettingItemFaceTracking ) ) ) ) |
|
1303 { |
|
1304 SetIntegerSettingValueL( ECamSettingItemFaceTracking, iPreviousFaceTrack ); |
|
1305 iPreviousFaceTrack = TCamSettingsOnOff( IntegerSettingValue( ECamSettingItemFaceTracking ) ); |
|
1306 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEnv->AppUi() ); |
|
1307 TRAP_IGNORE( appUi->APHandler()->UpdateActivePaletteL() ); |
|
1308 } |
|
1309 } |
|
1310 |
|
1311 // Update the engine with the scene settings. |
|
1312 //UpdateEngineWithSceneSettingsL( iPhotoScenes, aSceneId ); |
|
1313 } |
|
1314 |
|
1315 // Otherwise, activate the user scene settings |
|
1316 else |
|
1317 { |
|
1318 ActivateUserSceneSettingsL(); |
|
1319 } |
|
1320 iPreviousSceneMode = TCamSceneId( aSceneId ); // store scene mode setting |
|
1321 } |
|
1322 |
|
1323 // --------------------------------------------------------------------------- |
|
1324 // CCamSettingsModel::CopyUserSceneSettingToCaptureSettingL |
|
1325 // Copies a user scene setting across to the capture setup settings. |
|
1326 // --------------------------------------------------------------------------- |
|
1327 // |
|
1328 void CCamSettingsModel::CopyUserSceneSettingToCaptureSettingL( TInt aSettingItem ) |
|
1329 { |
|
1330 // Determine the indexes of the user scene setting and |
|
1331 // the corresponding photo capture setting. |
|
1332 |
|
1333 // ...determine the index of the user scene setting |
|
1334 TInt userIndex = SearchInSettingsListFor( iUserSceneSettings, |
|
1335 aSettingItem ); |
|
1336 |
|
1337 // ...determine the index of the corresponding photo capture setting |
|
1338 TInt capIndex = 0; |
|
1339 switch ( aSettingItem ) |
|
1340 { |
|
1341 case ECamSettingItemUserSceneWhitebalance: |
|
1342 { |
|
1343 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1344 ECamSettingItemDynamicPhotoWhiteBalance ); |
|
1345 } |
|
1346 break; |
|
1347 |
|
1348 case ECamSettingItemUserSceneExposure: |
|
1349 { |
|
1350 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1351 ECamSettingItemDynamicPhotoExposure ); |
|
1352 } |
|
1353 break; |
|
1354 |
|
1355 case ECamSettingItemUserSceneColourFilter: |
|
1356 { |
|
1357 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1358 ECamSettingItemDynamicPhotoColourFilter ); |
|
1359 } |
|
1360 break; |
|
1361 case ECamSettingItemUserSceneFlash: |
|
1362 { |
|
1363 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1364 ECamSettingItemDynamicPhotoFlash ); |
|
1365 } |
|
1366 break; |
|
1367 |
|
1368 case ECamSettingItemUserSceneBrightness: |
|
1369 { |
|
1370 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1371 ECamSettingItemDynamicPhotoBrightness ); |
|
1372 } |
|
1373 break; |
|
1374 case ECamSettingItemUserSceneContrast: |
|
1375 { |
|
1376 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1377 ECamSettingItemDynamicPhotoContrast ); |
|
1378 } |
|
1379 break; |
|
1380 |
|
1381 case ECamSettingItemUserSceneImageSharpness: |
|
1382 { |
|
1383 capIndex = SearchInSettingsListFor( iDynamicPhotoIntSettings, |
|
1384 ECamSettingItemDynamicPhotoImageSharpness ); |
|
1385 } |
|
1386 break; |
|
1387 |
|
1388 case ECamSettingItemUserSceneLightSensitivity: |
|
1389 { |
|
1390 capIndex = SearchInSettingsListFor(iDynamicPhotoIntSettings, |
|
1391 ECamSettingItemDynamicPhotoLightSensitivity ); |
|
1392 } |
|
1393 break; |
|
1394 default: |
|
1395 PRINT( _L("Camera => CCamSettingsModel::ECamPanicUnknownSettingItem 6" )) |
|
1396 CamPanic( ECamPanicUnknownSettingItem ); |
|
1397 break; |
|
1398 } |
|
1399 |
|
1400 // Copy the user scene setting across to the photo capture setting. |
|
1401 iDynamicPhotoIntSettings[capIndex]->iValueId = |
|
1402 iUserSceneSettings[userIndex]->iValueId; |
|
1403 |
|
1404 } |
|
1405 |
|
1406 |
|
1407 // --------------------------------------------------------------------------- |
|
1408 // CCamSettingsModel::ActivateUserSceneSettings |
|
1409 // Activates the current user scene settings. |
|
1410 // --------------------------------------------------------------------------- |
|
1411 // |
|
1412 void CCamSettingsModel::ActivateUserSceneSettingsL() |
|
1413 { |
|
1414 PRINT( _L("Camera => CCamSettingsModel::ActivateUserSceneSettingsL")) |
|
1415 // Copy all the user scene settings to capture settings. |
|
1416 CopyUserSceneSettingToCaptureSettingL( |
|
1417 ECamSettingItemUserSceneWhitebalance ); |
|
1418 CopyUserSceneSettingToCaptureSettingL( |
|
1419 ECamSettingItemUserSceneExposure ); |
|
1420 CopyUserSceneSettingToCaptureSettingL( |
|
1421 ECamSettingItemUserSceneColourFilter ); |
|
1422 CopyUserSceneSettingToCaptureSettingL( |
|
1423 ECamSettingItemUserSceneFlash ); |
|
1424 CopyUserSceneSettingToCaptureSettingL( |
|
1425 ECamSettingItemUserSceneBrightness ); |
|
1426 CopyUserSceneSettingToCaptureSettingL( |
|
1427 ECamSettingItemUserSceneContrast ); |
|
1428 CopyUserSceneSettingToCaptureSettingL( |
|
1429 ECamSettingItemUserSceneImageSharpness ); |
|
1430 |
|
1431 if ( iUiConfigManager->IsISOSupported() ) |
|
1432 { |
|
1433 CopyUserSceneSettingToCaptureSettingL( |
|
1434 ECamSettingItemUserSceneLightSensitivity ); |
|
1435 } |
|
1436 |
|
1437 // Handled in appcontroller |
|
1438 //UpdateEngineWithPhotoCaptureSetupSettingsL(); |
|
1439 PRINT( _L("Camera <= CCamSettingsModel::ActivateUserSceneSettingsL")) |
|
1440 } |
|
1441 |
|
1442 // --------------------------------------------------------------------------- |
|
1443 // CCamSettingsModel::VideoSceneHasChangedL |
|
1444 // Handles a change in the value for the video scene setting. |
|
1445 // That is, it updates the rest of the video dynamic setings. |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // |
|
1448 void CCamSettingsModel::VideoSceneHasChangedL( TInt aSettingValue ) |
|
1449 { |
|
1450 // Set all the video capture setup values to their defaults, |
|
1451 // except for the scene setting. |
|
1452 TInt settingsCount = iDynamicVideoIntSettings.Count(); |
|
1453 TInt i; |
|
1454 for ( i = 0; i < settingsCount; ++i ) |
|
1455 { |
|
1456 //video light is used for LED flash not for xenon flash |
|
1457 if ( iDynamicVideoIntSettings[i]->iItemId == ECamSettingItemDynamicVideoFlash ) |
|
1458 { |
|
1459 if ( iUiConfigManager->IsVideoLightSupported() && !iUiConfigManager->IsXenonFlashSupported() ) |
|
1460 { |
|
1461 // Set the capture setup flash setting to that of the new scene. |
|
1462 TInt sceneFlash = DefaultSettingValueForVideoScene( aSettingValue, ECamSettingItemSceneFlashMode ); |
|
1463 SetIntegerSettingValueL( ECamSettingItemDynamicVideoFlash, sceneFlash ); |
|
1464 } |
|
1465 } |
|
1466 // If the setting item is not the scene change it's value. |
|
1467 else if ( iDynamicVideoIntSettings[i]->iItemId != ECamSettingItemDynamicVideoScene ) |
|
1468 { |
|
1469 SetIntegerSettingValueL( iDynamicVideoIntSettings[i]->iItemId, |
|
1470 iDynamicVideoIntDefaults[i] ); |
|
1471 } |
|
1472 } |
|
1473 |
|
1474 // Update the engine with the scene settings. |
|
1475 //UpdateEngineWithSceneSettingsL( iVideoScenes, aSettingValue ); |
|
1476 } |
|
1477 |
|
1478 |
|
1479 // --------------------------------------------------------------------------- |
|
1480 // CCamSettingsModel::DefaultSettingValueForVideoScene |
|
1481 // Returns the default value of a setting for a video scene item. |
|
1482 // --------------------------------------------------------------------------- |
|
1483 // |
|
1484 TInt CCamSettingsModel::DefaultSettingValueForVideoScene( TInt aSceneId, TInt aSettingId ) const |
|
1485 { |
|
1486 TInt sceneIndex = FindSceneInSceneList( aSceneId, iVideoScenes ); |
|
1487 |
|
1488 TInt settingIndex = SearchInSettingsListFor( |
|
1489 iVideoScenes[sceneIndex]->iSettings, aSettingId ); |
|
1490 |
|
1491 return iVideoScenes[sceneIndex]->iSettings[settingIndex]->iValueId; |
|
1492 } |
|
1493 |
|
1494 |
|
1495 // --------------------------------------------------------------------------- |
|
1496 // CCamSettingsModel::PhotoSceneMaximumQuality |
|
1497 // Returns the highest allowed quality for the current photo scene. |
|
1498 // --------------------------------------------------------------------------- |
|
1499 // |
|
1500 TInt CCamSettingsModel::PhotoSceneMaximumQuality( TInt aSceneId ) const |
|
1501 { |
|
1502 // If the scene is the user scene return the maximum amount. |
|
1503 // This is to be changed once user scene has been implemented. |
|
1504 if ( aSceneId == ECamSceneUser ) |
|
1505 { |
|
1506 // Get the scene that the user scene is based on and |
|
1507 // get the maximum resolution for this scene. |
|
1508 TInt settingIndex = SearchInSettingsListFor( |
|
1509 iUserSceneSettings, ECamSettingItemUserSceneBasedOnScene ); |
|
1510 TInt sceneId = iUserSceneSettings[settingIndex]->iValueId; |
|
1511 |
|
1512 return PhotoSceneMaximumQuality( sceneId ); |
|
1513 } |
|
1514 |
|
1515 // Find the index to the scene. |
|
1516 TInt sceneIndex = FindSceneInSceneList( aSceneId, iPhotoScenes ); |
|
1517 // Search for the maximum resolution item in this scene's item list. |
|
1518 TInt settingsCount = iPhotoScenes[sceneIndex]->iSettings.Count(); |
|
1519 TInt i; |
|
1520 for ( i = 0; i < settingsCount; ++i ) |
|
1521 { |
|
1522 if ( iPhotoScenes[sceneIndex]->iSettings[i]->iItemId == ECamSettingItemSceneMaxRes ) |
|
1523 { |
|
1524 return iPhotoScenes[sceneIndex]->iSettings[i]->iValueId; |
|
1525 } |
|
1526 } |
|
1527 PRINT( _L("Camera => CCamSettingsModel::ECamPanicUnknownSettingItem 7" )) |
|
1528 CamPanic( ECamPanicUnknownSettingItem ); |
|
1529 // Remove warning |
|
1530 return KErrNotFound; |
|
1531 } |
|
1532 |
|
1533 |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // CCamSettingsModel::CurrentPhotoQualityValue |
|
1536 // Returns the current photo quality setting. |
|
1537 // --------------------------------------------------------------------------- |
|
1538 // |
|
1539 TInt CCamSettingsModel::CurrentPhotoQualityValue() const |
|
1540 { |
|
1541 return iStaticModel->IntegerSettingValue( ECamSettingItemPhotoQuality ); |
|
1542 } |
|
1543 |
|
1544 // --------------------------------------------------------------------------- |
|
1545 // CCamSettingsModel::PhotoQualityArrayIndex |
|
1546 // Returns the photo quailty array index of a specified photo quality id |
|
1547 // --------------------------------------------------------------------------- |
|
1548 // |
|
1549 |
|
1550 TInt CCamSettingsModel::PhotoQualityArrayIndex(TInt aPhotoQualityId) const |
|
1551 { |
|
1552 for(TInt i=0;i<iPhotoQualityLevels.Count();i++) |
|
1553 { |
|
1554 if(iPhotoQualityLevels[i].iPhotoQualityId == aPhotoQualityId) |
|
1555 { |
|
1556 return i; |
|
1557 } |
|
1558 } |
|
1559 return KErrNotFound; |
|
1560 } |
|
1561 |
|
1562 // --------------------------------------------------------------------------- |
|
1563 // CCamSettingsModel::CurrentPhotoCompression |
|
1564 // Returns the current photo quality level (value 1-100). |
|
1565 // --------------------------------------------------------------------------- |
|
1566 // |
|
1567 TInt CCamSettingsModel::CurrentPhotoCompression() const |
|
1568 { |
|
1569 TInt currentQualityLevel = PhotoQualityArrayIndex(CurrentPhotoQualityValue()); |
|
1570 |
|
1571 if ( currentQualityLevel != KErrNotFound ) |
|
1572 { |
|
1573 // Get the compression level for the current quality setting. |
|
1574 TCamPhotoQualitySetting quality = |
|
1575 iPhotoQualityLevels[currentQualityLevel]; |
|
1576 TInt compressionLevel = quality.iQualityLevel; |
|
1577 return compressionLevel; |
|
1578 } |
|
1579 |
|
1580 PRINT( _L("Camera => CCamSettingsModel::ECamPanicUnknownSettingItem 10" )) |
|
1581 CamPanic( ECamPanicUnknownSettingItem ); |
|
1582 // Remove warning |
|
1583 return KErrNotFound; |
|
1584 } |
|
1585 |
|
1586 |
|
1587 // --------------------------------------------------------------------------- |
|
1588 // CCamSettingsModel::CurrentPhotoResolution |
|
1589 // Returns the photo resolution from current Settings |
|
1590 // --------------------------------------------------------------------------- |
|
1591 // |
|
1592 TCamPhotoSizeId CCamSettingsModel::CurrentPhotoResolution() const |
|
1593 { |
|
1594 return PhotoResolution( CurrentPhotoQualityValue() ); |
|
1595 } |
|
1596 |
|
1597 // --------------------------------------------------------------------------- |
|
1598 // CCamSettingsModel::PhotoResolution |
|
1599 // Returns the photo resolution for a particular quality index |
|
1600 // --------------------------------------------------------------------------- |
|
1601 // |
|
1602 TCamPhotoSizeId CCamSettingsModel::PhotoResolution( TInt aQualityIndex ) const |
|
1603 { |
|
1604 TInt qualityValue = PhotoQualityArrayIndex( aQualityIndex ); |
|
1605 |
|
1606 if ( qualityValue != KErrNotFound ) |
|
1607 { |
|
1608 TCamPhotoQualitySetting quality = |
|
1609 iPhotoQualityLevels[qualityValue]; |
|
1610 |
|
1611 return iConfiguration.MapResolutionToPhotoSize( quality.iPhotoResolution ); |
|
1612 } |
|
1613 |
|
1614 PRINT( _L("Camera => CCamSettingsModel::ECamPanicUnknownSettingItem 11" )) |
|
1615 CamPanic( ECamPanicUnknownSettingItem ); |
|
1616 // Remove warning |
|
1617 return ECamPhotoSizeVGA; // We can never get here anyway |
|
1618 } |
|
1619 |
|
1620 // --------------------------------------------------------------------------- |
|
1621 // CCamSettingsModel::StorePrimaryCameraSettingsL |
|
1622 // Stores the primary camera settings so they can be reapplied when |
|
1623 // changing from front to back camera |
|
1624 // --------------------------------------------------------------------------- |
|
1625 // |
|
1626 void CCamSettingsModel::StorePrimaryCameraSettingsL() |
|
1627 { |
|
1628 PRINT( _L("Camera => CCamSettingsModel::StorePrimaryCameraSettingsL")) |
|
1629 iStaticModel->StorePrimaryCameraSettingsL(); |
|
1630 CopySettingsL(iDynamicPhotoIntSettings, iDynamicPhotoIntSettingsBackup); |
|
1631 CopySettingsL(iDynamicVideoIntSettings, iDynamicVideoIntSettingsBackup); |
|
1632 } |
|
1633 |
|
1634 // --------------------------------------------------------------------------- |
|
1635 // CCamSettingsModel::RestorePrimaryCameraSettingsL |
|
1636 // Restores the primary camera settings when |
|
1637 // changing from front to back camera |
|
1638 // --------------------------------------------------------------------------- |
|
1639 // |
|
1640 void CCamSettingsModel::RestorePrimaryCameraSettingsL() |
|
1641 { |
|
1642 // set the stored primary camera settings |
|
1643 iStaticModel->RestorePrimaryCameraSettingsL(); |
|
1644 CopySettingsL(iDynamicPhotoIntSettingsBackup, iDynamicPhotoIntSettings, ETrue); |
|
1645 CopySettingsL(iDynamicVideoIntSettingsBackup, iDynamicVideoIntSettings, ETrue); |
|
1646 CopySettingsL(iUserSceneSettingsBackup, iUserSceneSettings, ETrue); |
|
1647 } |
|
1648 |
|
1649 // --------------------------------------------------------------------------- |
|
1650 // VariantInfo |
|
1651 // --------------------------------------------------------------------------- |
|
1652 // |
|
1653 const TCamVariantInfo& |
|
1654 CCamSettingsModel::VariantInfo() |
|
1655 { |
|
1656 if( 0 > iVariantInfo.iFlags ) |
|
1657 { |
|
1658 TRAP_IGNORE( ReadVariantFlagsL() ); |
|
1659 } |
|
1660 return iVariantInfo; |
|
1661 } |
|
1662 |
|
1663 |
|
1664 // --------------------------------------------------------------------------- |
|
1665 // CCamSettingsModel::ResetRepository |
|
1666 // Reset Camera central repository file |
|
1667 // --------------------------------------------------------------------------- |
|
1668 // |
|
1669 void CCamSettingsModel::ResetRepository() |
|
1670 { |
|
1671 iStaticModel->ResetRepository(); |
|
1672 } |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 // =========================================================================== |
|
1678 // From base class MCamSettingPreviewHandler |
|
1679 |
|
1680 // --------------------------------------------------------------------------- |
|
1681 // |
|
1682 // --------------------------------------------------------------------------- |
|
1683 // |
|
1684 void |
|
1685 CCamSettingsModel::ActivatePreviewL( const TCamSettingItemIds& aSettingId, |
|
1686 TInt aSettingValue ) |
|
1687 { |
|
1688 TInt index = FindIndex( iSettingPreviews, aSettingId ); |
|
1689 if( KErrNotFound == index ) |
|
1690 { |
|
1691 // Preview for this setting id did not exist yet. |
|
1692 TIntSetting* settingItem = new (ELeave) TIntSetting; |
|
1693 CleanupStack::PushL( settingItem ); |
|
1694 |
|
1695 settingItem->iItemId = aSettingId; |
|
1696 settingItem->iValueId = aSettingValue; |
|
1697 |
|
1698 iSettingPreviews.AppendL( settingItem ); |
|
1699 CleanupStack::Pop( settingItem ); |
|
1700 } |
|
1701 else |
|
1702 { |
|
1703 // If a preview exists, only update the value. |
|
1704 // Only one preview per setting item active at once. |
|
1705 iSettingPreviews[index]->iValueId = aSettingValue; |
|
1706 } |
|
1707 // The preview is considered as current setting value. |
|
1708 // Notify observers as if the setting value had changed. |
|
1709 NotifyObservers( aSettingId, aSettingValue ); |
|
1710 } |
|
1711 |
|
1712 |
|
1713 // --------------------------------------------------------------------------- |
|
1714 // |
|
1715 // --------------------------------------------------------------------------- |
|
1716 // |
|
1717 void |
|
1718 CCamSettingsModel::CancelPreview( const TCamSettingItemIds& aSettingId ) |
|
1719 { |
|
1720 TInt index = FindIndex( iSettingPreviews, aSettingId ); |
|
1721 |
|
1722 if( KErrNotFound != index ) |
|
1723 { |
|
1724 TIntSetting* settingItem = iSettingPreviews[index]; |
|
1725 iSettingPreviews.Remove( index ); |
|
1726 delete settingItem; |
|
1727 settingItem = NULL; |
|
1728 } |
|
1729 } |
|
1730 |
|
1731 |
|
1732 // --------------------------------------------------------------------------- |
|
1733 // |
|
1734 // --------------------------------------------------------------------------- |
|
1735 // |
|
1736 void |
|
1737 CCamSettingsModel::CancelPreviews( const RArray<TCamSettingItemIds> aSettingIds ) |
|
1738 { |
|
1739 // Check if there is anything to cancel |
|
1740 if( 0 < iSettingPreviews.Count() ) |
|
1741 { |
|
1742 for( TInt i = 0; i < aSettingIds.Count(); i++ ) |
|
1743 { |
|
1744 CancelPreview( aSettingIds[i] ); |
|
1745 } |
|
1746 } |
|
1747 } |
|
1748 |
|
1749 |
|
1750 // --------------------------------------------------------------------------- |
|
1751 // |
|
1752 // --------------------------------------------------------------------------- |
|
1753 // |
|
1754 void |
|
1755 CCamSettingsModel::CancelAllPreviews() |
|
1756 { |
|
1757 iSettingPreviews.ResetAndDestroy(); |
|
1758 } |
|
1759 |
|
1760 |
|
1761 // --------------------------------------------------------------------------- |
|
1762 // |
|
1763 // --------------------------------------------------------------------------- |
|
1764 // |
|
1765 void |
|
1766 CCamSettingsModel::CommitPreviewL( const TCamSettingItemIds& aSettingId ) |
|
1767 { |
|
1768 TInt index = FindIndex( iSettingPreviews, aSettingId ); |
|
1769 |
|
1770 if( KErrNotFound != index ) |
|
1771 { |
|
1772 TIntSetting* settingItem = iSettingPreviews[index]; |
|
1773 |
|
1774 iSettingPreviews.Remove( index ); |
|
1775 |
|
1776 CleanupStack::PushL( settingItem ); |
|
1777 SetIntegerSettingValueL( settingItem->iItemId, settingItem->iValueId ); |
|
1778 CleanupStack::PopAndDestroy( settingItem ); |
|
1779 } |
|
1780 else |
|
1781 { |
|
1782 User::Leave( KErrNotFound ); |
|
1783 } |
|
1784 } |
|
1785 |
|
1786 |
|
1787 // --------------------------------------------------------------------------- |
|
1788 // |
|
1789 // --------------------------------------------------------------------------- |
|
1790 // |
|
1791 void |
|
1792 CCamSettingsModel::CommitPreviewsL( const RArray<TCamSettingItemIds>& aSettingIds ) |
|
1793 { |
|
1794 if( 0 < iSettingPreviews.Count() ) |
|
1795 { |
|
1796 TInt all ( KErrNone ); |
|
1797 TInt single( KErrNone ); |
|
1798 |
|
1799 for( TInt i = 0; i < aSettingIds.Count(); i++ ) |
|
1800 { |
|
1801 TRAP( single, CommitPreviewL( aSettingIds[i] ) ); |
|
1802 |
|
1803 if( KErrNone != single ) |
|
1804 all = single; |
|
1805 } |
|
1806 |
|
1807 // Leave if there was problem with any of the previews. |
|
1808 User::LeaveIfError( all ); |
|
1809 } |
|
1810 } |
|
1811 |
|
1812 |
|
1813 // --------------------------------------------------------------------------- |
|
1814 // |
|
1815 // --------------------------------------------------------------------------- |
|
1816 // |
|
1817 void |
|
1818 CCamSettingsModel::CommitAllPreviewsL() |
|
1819 { |
|
1820 TInt all ( KErrNone ); |
|
1821 TInt single( KErrNone ); |
|
1822 for( TInt i = 0; i < iSettingPreviews.Count(); i++ ) |
|
1823 { |
|
1824 TRAP( single, SetIntegerSettingValueL( iSettingPreviews[i]->iItemId, |
|
1825 iSettingPreviews[i]->iValueId ) ); |
|
1826 |
|
1827 if( KErrNone != single ) |
|
1828 all = single; |
|
1829 } |
|
1830 |
|
1831 // Even if all commits are not successful, deactivate all previews. |
|
1832 iSettingPreviews.ResetAndDestroy(); |
|
1833 |
|
1834 // Leave if there was problem with any of the previews. |
|
1835 User::LeaveIfError( all ); |
|
1836 } |
|
1837 |
|
1838 |
|
1839 // --------------------------------------------------------------------------- |
|
1840 // |
|
1841 // --------------------------------------------------------------------------- |
|
1842 // |
|
1843 void |
|
1844 CCamSettingsModel |
|
1845 ::ActivePreviewsL( RArray<TCamSettingItemIds>& aSettingIds ) const |
|
1846 { |
|
1847 aSettingIds.Reset(); |
|
1848 aSettingIds.ReserveL( iSettingPreviews.Count() ); |
|
1849 for( TInt i = 0; i < iSettingPreviews.Count(); i++ ) |
|
1850 { |
|
1851 aSettingIds.AppendL( (TCamSettingItemIds)iSettingPreviews[i]->iItemId ); |
|
1852 } |
|
1853 } |
|
1854 |
|
1855 // =========================================================================== |
|
1856 |
|
1857 |
|
1858 |
|
1859 // --------------------------------------------------------------------------- |
|
1860 // CCamSettingsModel::ImageResolutionFromIndex |
|
1861 // Returns the dimensions of the photo (in pixels) based on the size ID passed in |
|
1862 // --------------------------------------------------------------------------- |
|
1863 // |
|
1864 TSize CCamSettingsModel::ImageResolutionFromIndex( TCamPhotoSizeId aIndex ) |
|
1865 { |
|
1866 // TCamImageResolution imageRes = iConfiguration.MapPhotoSizeToResolution( aIndex ); |
|
1867 return iPhotoResolutions[aIndex]; |
|
1868 } |
|
1869 |
|
1870 // --------------------------------------------------------------------------- |
|
1871 // CCamSettingsModel::DefaultSettingValueForScene |
|
1872 // Returns the default value of a setting for a particular scene item. |
|
1873 // --------------------------------------------------------------------------- |
|
1874 // |
|
1875 TInt CCamSettingsModel::DefaultSettingValueForScene( TInt aSceneId, TInt aSettingId ) const |
|
1876 { |
|
1877 TInt sceneIndex = FindSceneInSceneList( aSceneId, iPhotoScenes ); |
|
1878 |
|
1879 TInt settingIndex = SearchInSettingsListFor( |
|
1880 iPhotoScenes[sceneIndex]->iSettings, aSettingId ); |
|
1881 |
|
1882 return iPhotoScenes[sceneIndex]->iSettings[settingIndex]->iValueId; |
|
1883 } |
|
1884 |
|
1885 |
|
1886 // --------------------------------------------------------------------------- |
|
1887 // CCamSettingsModel::LoadDynamicSettingsL |
|
1888 // Loads the dynamic settings from resource file for a |
|
1889 // particular group of settings, and stores their defaults. |
|
1890 // --------------------------------------------------------------------------- |
|
1891 // |
|
1892 void CCamSettingsModel::LoadDynamicSettingsL( |
|
1893 TInt aResourceId, |
|
1894 RPointerArray<TIntSetting>& aSettingsList, |
|
1895 RArray<TInt>& aDefaultsList ) |
|
1896 { |
|
1897 PRINT( _L("Camera => CCamSettingsModel::LoadDynamicSettingsL" )) |
|
1898 // Create resource reader for reading photo static settings |
|
1899 TResourceReader reader; |
|
1900 iEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
1901 TInt count = reader.ReadInt16(); |
|
1902 |
|
1903 // for each entry in the resource, create a new setting item. |
|
1904 TInt i; |
|
1905 for ( i = 0; i < count; ++i ) |
|
1906 { |
|
1907 |
|
1908 TIntSetting* newSetting = new (ELeave) TIntSetting; |
|
1909 CleanupStack::PushL( newSetting ); |
|
1910 |
|
1911 // Read the data for this setting item from resource. |
|
1912 newSetting->iItemId = reader.ReadInt16(); |
|
1913 newSetting->iValueId = reader.ReadInt16(); |
|
1914 aDefaultsList.AppendL( newSetting->iValueId ); |
|
1915 |
|
1916 // Add the new setting item and its associated key |
|
1917 // to the parallel arrays for static photo settings. |
|
1918 aSettingsList.AppendL( newSetting ); |
|
1919 CleanupStack::Pop( newSetting ); |
|
1920 } |
|
1921 |
|
1922 CleanupStack::PopAndDestroy(); // reader |
|
1923 PRINT( _L("Camera <= CCamSettingsModel::LoadDynamicSettingsL" )) |
|
1924 } |
|
1925 |
|
1926 // --------------------------------------------------------------------------- |
|
1927 // CCamSettingsModel::LoadDynamicSettingsL |
|
1928 // Loads the dynamic settings from resource file for a |
|
1929 // particular group of settings. |
|
1930 // --------------------------------------------------------------------------- |
|
1931 // |
|
1932 void CCamSettingsModel::LoadDynamicSettingsL( TInt aResourceId, |
|
1933 RPointerArray<TIntSetting>& aSettingsList ) |
|
1934 { |
|
1935 iStaticModel->LoadSettingsFromResourceL( aResourceId, aSettingsList ); |
|
1936 } |
|
1937 |
|
1938 |
|
1939 // --------------------------------------------------------------------------- |
|
1940 // CCamSettingsModel::LoadScenesDataL |
|
1941 // Loads the scene data from resource file for a particular group of scenes. |
|
1942 // --------------------------------------------------------------------------- |
|
1943 // |
|
1944 void CCamSettingsModel::LoadScenesDataL( TInt aResourceId, |
|
1945 RPointerArray<TSceneData >& aSceneDataArray ) |
|
1946 { |
|
1947 // Add array of defaults for static video settings |
|
1948 TResourceReader reader; |
|
1949 // Add array of defaults for static video settings |
|
1950 iEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
1951 TInt sceneCount = reader.ReadInt16(); |
|
1952 |
|
1953 // for each entry in the resource array, create a new scene data item |
|
1954 TInt i; |
|
1955 for ( i = 0; i < sceneCount; i++ ) |
|
1956 { |
|
1957 TSceneData * sceneData = new (ELeave) TSceneData ; |
|
1958 CleanupStack::PushL( sceneData ); |
|
1959 |
|
1960 // Create a resource reader for reading only this scene's data. |
|
1961 TInt resourceID = reader.ReadInt32(); |
|
1962 TResourceReader localReader; |
|
1963 iEnv->CreateResourceReaderLC |
|
1964 ( localReader, resourceID ); |
|
1965 |
|
1966 // Read the data for this list item from resource. |
|
1967 // ...read scene id for the scene data |
|
1968 sceneData->iSceneId = localReader.ReadInt16(); |
|
1969 // ...read settings for the scene data. |
|
1970 TInt settingsCount = localReader.ReadInt16(); |
|
1971 TInt j; |
|
1972 for ( j = 0; j < settingsCount; ++j ) |
|
1973 { |
|
1974 TIntSetting* setting = new (ELeave) TIntSetting; |
|
1975 CleanupStack::PushL( setting ); |
|
1976 sceneData->iSettings.AppendL( setting ); |
|
1977 CleanupStack::Pop( setting ); |
|
1978 sceneData->iSettings[j]->iItemId = localReader.ReadInt16(); |
|
1979 sceneData->iSettings[j]->iValueId = localReader.ReadInt16(); |
|
1980 } |
|
1981 |
|
1982 CleanupStack::PopAndDestroy(); // local reader |
|
1983 |
|
1984 // Add the scene data to the scenes list. |
|
1985 aSceneDataArray.AppendL( sceneData ); |
|
1986 CleanupStack::Pop( sceneData ); |
|
1987 } |
|
1988 |
|
1989 CleanupStack::PopAndDestroy(); // reader |
|
1990 } |
|
1991 |
|
1992 // --------------------------------------------------------------------------- |
|
1993 // CCamSettingsModel::LoadSceneDataL |
|
1994 // Loads the scene data from resource file for a particular group of scenes. |
|
1995 // --------------------------------------------------------------------------- |
|
1996 // |
|
1997 void CCamSettingsModel::LoadSceneDataL( TBool aPhotoSceneSettings ) |
|
1998 { |
|
1999 RArray<TSceneSettings> supportedSceneSettings; |
|
2000 CleanupClosePushL( supportedSceneSettings ); |
|
2001 |
|
2002 iUiConfigManager->SupportedSceneModesAndSettingsL( supportedSceneSettings, |
|
2003 aPhotoSceneSettings ); |
|
2004 |
|
2005 for ( TInt i = 0; i < supportedSceneSettings.Count(); i++ ) |
|
2006 { |
|
2007 // |
|
2008 TSceneSettings scene = supportedSceneSettings[i]; |
|
2009 if ( scene.iSupported ) // only if scenes are supported its appened to the list |
|
2010 { |
|
2011 TSceneData* sceneData = new ( ELeave ) TSceneData; |
|
2012 CleanupStack::PushL( sceneData ); |
|
2013 |
|
2014 // identifier |
|
2015 sceneData->iSceneId = scene.iIdentifier; |
|
2016 |
|
2017 // exposure mode |
|
2018 TIntSetting* setting = new ( ELeave ) TIntSetting; |
|
2019 CleanupStack::PushL( setting ); |
|
2020 |
|
2021 setting->iItemId = ECamSettingItemSceneAEMode; |
|
2022 setting->iValueId = scene.iExposureMode; |
|
2023 |
|
2024 sceneData->iSettings.AppendL( setting ); |
|
2025 CleanupStack::Pop( setting ); |
|
2026 |
|
2027 // white balance |
|
2028 setting = new ( ELeave ) TIntSetting; |
|
2029 CleanupStack::PushL( setting ); |
|
2030 |
|
2031 setting->iItemId = ECamSettingItemSceneAWBMode; |
|
2032 setting->iValueId = scene.iWhiteBalance; |
|
2033 |
|
2034 sceneData->iSettings.AppendL( setting ); |
|
2035 CleanupStack::Pop( setting ); |
|
2036 |
|
2037 // flash |
|
2038 setting = new ( ELeave ) TIntSetting; |
|
2039 CleanupStack::PushL( setting ); |
|
2040 |
|
2041 setting->iItemId = ECamSettingItemSceneFlashMode; |
|
2042 setting->iValueId = scene.iFlash; |
|
2043 |
|
2044 sceneData->iSettings.AppendL( setting ); |
|
2045 CleanupStack::Pop( setting ); |
|
2046 |
|
2047 // contrast |
|
2048 setting = new ( ELeave ) TIntSetting; |
|
2049 CleanupStack::PushL( setting ); |
|
2050 |
|
2051 setting->iItemId = ECamSettingItemSceneContrast; |
|
2052 setting->iValueId = scene.iContrastMode; |
|
2053 |
|
2054 sceneData->iSettings.AppendL( setting ); |
|
2055 CleanupStack::Pop( setting ); |
|
2056 |
|
2057 // focal distance |
|
2058 setting = new ( ELeave ) TIntSetting; |
|
2059 CleanupStack::PushL( setting ); |
|
2060 |
|
2061 setting->iItemId = ECamSettingItemSceneAFMode; |
|
2062 setting->iValueId = scene.iFocalDistance; |
|
2063 |
|
2064 sceneData->iSettings.AppendL( setting ); |
|
2065 CleanupStack::Pop( setting ); |
|
2066 |
|
2067 |
|
2068 if ( aPhotoSceneSettings ) |
|
2069 { |
|
2070 // load settings which are specific to photo scene |
|
2071 |
|
2072 // sharpness |
|
2073 setting = new ( ELeave ) TIntSetting; |
|
2074 CleanupStack::PushL( setting ); |
|
2075 |
|
2076 setting->iItemId = ECamSettingItemSceneSharpness; |
|
2077 setting->iValueId = scene.iSharpnessMode; |
|
2078 |
|
2079 sceneData->iSettings.AppendL( setting ); |
|
2080 CleanupStack::Pop( setting ); |
|
2081 |
|
2082 |
|
2083 // ISO |
|
2084 setting = new ( ELeave ) TIntSetting; |
|
2085 CleanupStack::PushL( setting ); |
|
2086 |
|
2087 setting->iItemId = ECamSettingItemSceneISO; |
|
2088 setting->iValueId = scene.iLightSensitivityMode; |
|
2089 |
|
2090 sceneData->iSettings.AppendL( setting ); |
|
2091 CleanupStack::Pop( setting ); |
|
2092 |
|
2093 // EV |
|
2094 setting = new ( ELeave ) TIntSetting; |
|
2095 CleanupStack::PushL( setting ); |
|
2096 |
|
2097 setting->iItemId = ECamSettingItemSceneEV; |
|
2098 setting->iValueId = scene.iExposureCompensationValue; |
|
2099 |
|
2100 sceneData->iSettings.AppendL( setting ); |
|
2101 CleanupStack::Pop( setting ); |
|
2102 } |
|
2103 else |
|
2104 { |
|
2105 // settings which are specific to video scene |
|
2106 // framerate |
|
2107 setting = new ( ELeave ) TIntSetting; |
|
2108 CleanupStack::PushL( setting ); |
|
2109 |
|
2110 setting->iItemId = ECamSettingItemSceneFramerate; |
|
2111 setting->iValueId = scene.iFrameRate; |
|
2112 |
|
2113 sceneData->iSettings.AppendL( setting ); |
|
2114 CleanupStack::Pop( setting ); |
|
2115 } |
|
2116 // Add the scene data to the scenes list. |
|
2117 if ( aPhotoSceneSettings ) |
|
2118 { |
|
2119 iPhotoScenes.AppendL( sceneData ); |
|
2120 } |
|
2121 else |
|
2122 { |
|
2123 iVideoScenes.AppendL( sceneData ); |
|
2124 } |
|
2125 CleanupStack::Pop( sceneData ); |
|
2126 } // end if |
|
2127 } // end for |
|
2128 CleanupStack::PopAndDestroy( &supportedSceneSettings ); |
|
2129 } |
|
2130 |
|
2131 // --------------------------------------------------------------------------- |
|
2132 // CCamSettingsModel::UnloadSettings |
|
2133 // Remove any previously loaded settings. |
|
2134 // --------------------------------------------------------------------------- |
|
2135 // |
|
2136 void CCamSettingsModel::UnloadSettings() |
|
2137 { |
|
2138 PRINT( _L("Camera => CCamSettingsModel::UnloadSettings()" )) |
|
2139 |
|
2140 iDynamicPhotoIntSettings.ResetAndDestroy(); |
|
2141 iDynamicVideoIntSettings.ResetAndDestroy(); |
|
2142 |
|
2143 iPhotoScenes.ResetAndDestroy(); |
|
2144 iVideoScenes.ResetAndDestroy(); |
|
2145 PRINT( _L("Camera <= CCamSettingsModel::UnloadSettings()" )) |
|
2146 } |
|
2147 |
|
2148 // --------------------------------------------------------------------------- |
|
2149 // CCamSettingsModel::UnloadStaticSettings |
|
2150 // Remove any previously loaded static settings. |
|
2151 // --------------------------------------------------------------------------- |
|
2152 // |
|
2153 void CCamSettingsModel::UnloadStaticSettings() |
|
2154 { |
|
2155 PRINT( _L("Camera => CCamSettingsModel::UnloadStaticSettings()" )) |
|
2156 iUserSceneSettings.ResetAndDestroy(); |
|
2157 PRINT( _L("Camera <= CCamSettingsModel::UnloadStaticSettings()" )) |
|
2158 } |
|
2159 |
|
2160 // --------------------------------------------------------------------------- |
|
2161 // CCamSettingsModel::BurstModeActiveL |
|
2162 // Track burst mode activation |
|
2163 // --------------------------------------------------------------------------- |
|
2164 // |
|
2165 void |
|
2166 CCamSettingsModel::BurstModeActiveL( TBool aActive, TBool /*aStillModeActive*/ ) |
|
2167 { |
|
2168 iBurstEnabled = aActive; |
|
2169 } |
|
2170 |
|
2171 |
|
2172 // --------------------------------------------------------------------------- |
|
2173 // CCamSettingsModel::VideoResolutions |
|
2174 // Return ref. to video resolutions array |
|
2175 // --------------------------------------------------------------------------- |
|
2176 // |
|
2177 const RArray<TSize>& |
|
2178 CCamSettingsModel::VideoResolutions() |
|
2179 { |
|
2180 return iVideoResolutions; |
|
2181 } |
|
2182 |
|
2183 // --------------------------------------------------------------------------- |
|
2184 // CCamSettingsModel::VideoQualityArray |
|
2185 // Return ref. to video video quality level array |
|
2186 // --------------------------------------------------------------------------- |
|
2187 // |
|
2188 const RPointerArray<CCamVideoQualityLevel>& |
|
2189 CCamSettingsModel::VideoQualityArray() |
|
2190 { |
|
2191 return iQualityLevels; |
|
2192 } |
|
2193 |
|
2194 // --------------------------------------------------------------------------- |
|
2195 // StaticSettingsModel |
|
2196 // |
|
2197 // Gets the reference to the settings model |
|
2198 // --------------------------------------------------------------------------- |
|
2199 // |
|
2200 MCamStaticSettings& |
|
2201 CCamSettingsModel::StaticSettingsModel() const |
|
2202 { |
|
2203 return *iStaticModel; |
|
2204 } |
|
2205 |
|
2206 // =========================================================================== |
|
2207 // TSceneData methods |
|
2208 |
|
2209 // --------------------------------------------------------------------------- |
|
2210 // TSceneData::~TSceneData |
|
2211 // Destructor |
|
2212 // --------------------------------------------------------------------------- |
|
2213 // |
|
2214 TSceneData::~TSceneData() |
|
2215 { |
|
2216 iSettings.ResetAndDestroy(); |
|
2217 iSettings.Close(); |
|
2218 } |
|
2219 |
|
2220 /* |
|
2221 * Is Image Scene supported |
|
2222 */ |
|
2223 TBool CCamSettingsModel::IsImageSceneSupported( const TInt aSceneId ) const |
|
2224 { |
|
2225 if ( ECamSceneMacro == aSceneId && !iUiConfigManager->IsAutoFocusSupported() ) |
|
2226 { |
|
2227 // if the photo scene is macro and if autofocus is not supported |
|
2228 // the macro scene mode is not visible in scene mode settings |
|
2229 return EFalse; |
|
2230 } |
|
2231 return ( KErrNotFound != FindSceneInSceneList( aSceneId, iPhotoScenes ) ); |
|
2232 } |
|
2233 |
|
2234 /* |
|
2235 * Is Image Scene supported |
|
2236 */ |
|
2237 TBool CCamSettingsModel::IsVideoSceneSupported( const TInt aSceneId ) const |
|
2238 { |
|
2239 return ( KErrNotFound != FindSceneInSceneList( aSceneId, iVideoScenes ) ); |
|
2240 } |
|
2241 |
|
2242 /* |
|
2243 * Handle to Camera Ui Config Manager |
|
2244 */ |
|
2245 CCameraUiConfigManager* CCamSettingsModel::UiConfigManagerPtr() |
|
2246 { |
|
2247 return iUiConfigManager; |
|
2248 } |
|
2249 |
|
2250 |
|
2251 // --------------------------------------------------------------------------- |
|
2252 // |
|
2253 // --------------------------------------------------------------------------- |
|
2254 // |
|
2255 void CCamSettingsModel::LoadResourcesL() |
|
2256 { |
|
2257 PRINT( _L("Camera => CCamSettingsModel::LoadResourcesL" ) ) |
|
2258 if (iResourceFileOffset == 0) |
|
2259 { |
|
2260 TFileName resourceFile; |
|
2261 TParse parse; |
|
2262 if ( CamUtility::IsNhdDevice() ) |
|
2263 { |
|
2264 parse.Set( KCamNhdResourceFileName, &KDC_APP_RESOURCE_DIR, NULL ); |
|
2265 } |
|
2266 else |
|
2267 { |
|
2268 parse.Set( KCamVgaResourceFileName, &KDC_APP_RESOURCE_DIR, NULL ); |
|
2269 } |
|
2270 resourceFile = parse.FullName(); |
|
2271 BaflUtils::NearestLanguageFile( iEnv->FsSession(), resourceFile ); |
|
2272 iResourceFileOffset = iEnv->AddResourceFileL( resourceFile ); |
|
2273 } |
|
2274 PRINT( _L("Camera <= CCamSettingsModel::LoadResourcesL" ) ) |
|
2275 } |
|
2276 |
|
2277 |
|
2278 // --------------------------------------------------------------------------- |
|
2279 // |
|
2280 // --------------------------------------------------------------------------- |
|
2281 // |
|
2282 void CCamSettingsModel::UnLoadResources() |
|
2283 { |
|
2284 if (iResourceFileOffset > 0) |
|
2285 { |
|
2286 iEnv->DeleteResourceFile( iResourceFileOffset ); |
|
2287 iResourceFileOffset = 0; |
|
2288 } |
|
2289 } |
|
2290 |
|
2291 // --------------------------------------------------------------------------- |
|
2292 // CCamSettingsModel::StoreFaceTrackingValue |
|
2293 // |
|
2294 // Store user defined FT value outside Sports and Scenery mode that setting |
|
2295 // can be rolled back. |
|
2296 // --------------------------------------------------------------------------- |
|
2297 // |
|
2298 void CCamSettingsModel::StoreFaceTrackingValue() |
|
2299 { |
|
2300 PRINT( _L("Camera => CCamSettingsModel::StoreFaceTrackingValue()" ) ) |
|
2301 |
|
2302 if ( !iUiConfigManager->IsFaceTrackingSupported() ) // FT not supported |
|
2303 { |
|
2304 PRINT( _L("Camera <= CCamSettingsModel::StoreFaceTrackingValue(), FT _not_ supported" ) ) |
|
2305 return; |
|
2306 } |
|
2307 TInt activeScene = IntegerSettingValue( ECamSettingItemDynamicPhotoScene ); |
|
2308 if ( ECamSceneScenery == activeScene || ECamSceneSports == activeScene ) |
|
2309 { |
|
2310 PRINT( _L("Camera <> CCamSettingsModel::StoreFaceTrackingValue(), Scenery or Sports mode" ) ) |
|
2311 if ( iPreviousFaceTrack != TCamSettingsOnOff( IntegerSettingValue( ECamSettingItemFaceTracking ) ) ) |
|
2312 { |
|
2313 PRINT1( _L("Camera <> CCamSettingsModel::StoreFaceTrackingValue(), iPreviousFaceTrack [%d]" ), iPreviousFaceTrack ) |
|
2314 SetIntegerSettingValueL( ECamSettingItemFaceTracking, iPreviousFaceTrack ); |
|
2315 } |
|
2316 } |
|
2317 PRINT( _L("Camera <= CamSettingsModel::StoreFaceTrackingValue()" ) ) |
|
2318 } |
|
2319 |
|
2320 // --------------------------------------------------------------------------- |
|
2321 // CCamSettingsModel::CopySettingsL |
|
2322 // |
|
2323 // Backup and Restore Settings array |
|
2324 // --------------------------------------------------------------------------- |
|
2325 // |
|
2326 void CCamSettingsModel::CopySettingsL(RPointerArray<TIntSetting>& aSrc, |
|
2327 RPointerArray<TIntSetting>& aDest, |
|
2328 TBool aRestore) |
|
2329 { |
|
2330 if(aRestore) |
|
2331 { |
|
2332 __ASSERT_DEBUG(aSrc.Count() == aDest.Count(), CamPanic(ECamPanicInvalidState)); |
|
2333 TInt count = aSrc.Count(); |
|
2334 TInt index = 0; |
|
2335 do |
|
2336 { |
|
2337 if(aSrc[index]->iItemId == aDest[index]->iItemId) |
|
2338 { |
|
2339 if(aSrc[index]->iValueId != aDest[index]->iValueId) |
|
2340 { |
|
2341 aDest[index]->iValueId = aSrc[index]->iValueId; |
|
2342 } |
|
2343 } |
|
2344 index++; |
|
2345 }while(index < count); |
|
2346 } |
|
2347 else |
|
2348 { |
|
2349 __ASSERT_DEBUG(aSrc.Count(), CamPanic(ECamPanicInvalidState)); |
|
2350 aDest.ResetAndDestroy(); |
|
2351 TInt count = aSrc.Count(); |
|
2352 TInt index = 0; |
|
2353 do |
|
2354 { |
|
2355 TIntSetting* setting = new(ELeave) TIntSetting(); |
|
2356 CleanupStack::PushL(setting); |
|
2357 setting->iItemId = aSrc[index]->iItemId; |
|
2358 setting->iValueId = aSrc[index]->iValueId; |
|
2359 aDest.AppendL(setting); |
|
2360 CleanupStack::Pop(setting); |
|
2361 index++; |
|
2362 }while(index < count); |
|
2363 } |
|
2364 } |
|
2365 |
|
2366 // --------------------------------------------------------------------------- |
|
2367 // CCamSettingsModel::StoreUserSceneSettingsL |
|
2368 // |
|
2369 // Store UserScene Settings |
|
2370 // --------------------------------------------------------------------------- |
|
2371 // |
|
2372 void CCamSettingsModel::StoreUserSceneSettingsL() |
|
2373 { |
|
2374 CopySettingsL(iUserSceneSettings, iUserSceneSettingsBackup); |
|
2375 } |
|
2376 |
|
2377 // =========================================================================== |
|
2378 // end of File |
|