1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Manages all static settings data.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // =========================================================================== |
|
20 // Includes |
|
21 |
|
22 #include <StringLoader.h> |
|
23 #include <barsread.h> |
|
24 #include <AknQueryDialog.h> |
|
25 #include <ecam.h> |
|
26 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
27 #include <cameraapp.rsg> |
|
28 #include <vgacamsettings.rsg> |
|
29 #include "camsettingconversion.h" |
|
30 #else |
|
31 #include <gscamerapluginrsc.rsg> |
|
32 #endif |
|
33 |
|
34 #include "CamStaticSettingsModel.h" |
|
35 #include "CamUtility.h" |
|
36 #include "CamPanic.h" |
|
37 #include "CamAppUiBase.h" |
|
38 #include "CamVideoQualityLevel.h" |
|
39 #include "CameraappPrivateCRKeys.h" // CR keys |
|
40 #include "CameraUiConfigManager.h" |
|
41 #include "camconfiguration.h" |
|
42 |
|
43 |
|
44 // =========================================================================== |
|
45 // Constants |
|
46 |
|
47 const TInt KCamCRStringInitialLength = 64; |
|
48 const TInt KCamUseDefaultVideoQuality = -1; |
|
49 |
|
50 // =========================================================================== |
|
51 // Local methods |
|
52 |
|
53 inline TBool SettingIdMatches( const TInt* aSettingId, |
|
54 const TIntSetting& aSettingItem ) |
|
55 { |
|
56 return (*aSettingId == aSettingItem.iItemId); |
|
57 }; |
|
58 |
|
59 |
|
60 // =========================================================================== |
|
61 // Class methods |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CCamStaticSettingsModel::NewL |
|
65 // Symbian OS two-phased constructor |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CCamStaticSettingsModel* |
|
69 CCamStaticSettingsModel::NewL( CCamConfiguration& aConfiguration ) |
|
70 { |
|
71 CCamStaticSettingsModel* self |
|
72 = CCamStaticSettingsModel::NewLC( aConfiguration ); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CCamStaticSettingsModel::NewLC |
|
79 // Symbian OS two-phased constructor |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CCamStaticSettingsModel* |
|
83 CCamStaticSettingsModel::NewLC( CCamConfiguration& aConfiguration ) |
|
84 { |
|
85 CCamStaticSettingsModel* self |
|
86 = new( ELeave ) CCamStaticSettingsModel( aConfiguration ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CCamStaticSettingsModel::IntegerSettingValue |
|
95 // Returns the current integer value for the specified setting |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 TInt |
|
99 CCamStaticSettingsModel::IntegerSettingValue( TInt aSettingItem ) const |
|
100 { |
|
101 TInt value = KErrNotFound; |
|
102 // If setting item is in the static photo settings return it's value. |
|
103 if( ECamSettingItemStaticPhotoRangeMax > aSettingItem |
|
104 && ECamSettingItemStaticPhotoRangeMin < aSettingItem ) |
|
105 { |
|
106 TInt settingIndex = SearchInSettingsListFor( |
|
107 iStaticPhotoIntSettings, |
|
108 aSettingItem ); |
|
109 value = iStaticPhotoIntSettings[settingIndex]->iValueId; |
|
110 } |
|
111 // Otherwise, if setting item is in the static video settings return it's value. |
|
112 else if( ECamSettingItemStaticVideoRangeMax > aSettingItem |
|
113 && ECamSettingItemStaticVideoRangeMin < aSettingItem ) |
|
114 { |
|
115 TInt settingIndex = SearchInSettingsListFor( iStaticVideoIntSettings, aSettingItem ); |
|
116 value = iStaticVideoIntSettings[settingIndex]->iValueId; |
|
117 } |
|
118 // Look in static common settings. |
|
119 else if( ECamSettingItemStaticCommonRangeMax > aSettingItem |
|
120 && ECamSettingItemStaticCommonRangeMin < aSettingItem ) |
|
121 { |
|
122 TInt settingIndex = SearchInSettingsListFor( iStaticCommonIntSettings, aSettingItem ); |
|
123 value = iStaticCommonIntSettings[settingIndex]->iValueId; |
|
124 } |
|
125 else |
|
126 { |
|
127 PRINT( _L("Camera <> Not found, PANIC !! ECamPanicUnknownSettingItem" )) |
|
128 CamPanic( ECamPanicUnknownSettingItem ); |
|
129 } |
|
130 return value; |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CCamStaticSettingsModel::SetIntegerSettingValueL |
|
136 // Sets a new integer value for the specified setting |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void |
|
140 CCamStaticSettingsModel::SetIntegerSettingValueL( TInt aSettingItem, |
|
141 TInt aSettingValue ) |
|
142 { |
|
143 TCamSettingItemIds settingId( |
|
144 static_cast<TCamSettingItemIds>(aSettingItem) ); |
|
145 |
|
146 // Static image settings |
|
147 if( ECamSettingItemStaticPhotoRangeMin < settingId |
|
148 && ECamSettingItemStaticPhotoRangeMax > settingId ) |
|
149 { |
|
150 PRINT( _L("Camera <> static photo setting") ); |
|
151 TInt settingIndex = SearchInSettingsListFor( iStaticPhotoIntSettings, settingId ); |
|
152 iStaticPhotoIntSettings[settingIndex]->iValueId = aSettingValue; |
|
153 SaveStaticSettingL( settingId ); |
|
154 |
|
155 // Video / photo storage settings follow eachother |
|
156 if ( ECamSettingItemPhotoMediaStorage == settingId ) |
|
157 { |
|
158 TInt index = SearchInSettingsListFor( iStaticVideoIntSettings, |
|
159 ECamSettingItemVideoMediaStorage ); |
|
160 if ( index != KErrNotFound ) |
|
161 { |
|
162 iStaticVideoIntSettings[index]->iValueId = aSettingValue; |
|
163 SaveStaticSettingL( ECamSettingItemVideoMediaStorage ); |
|
164 } |
|
165 } |
|
166 } |
|
167 // ------------------------------------------------------- |
|
168 // Static video settings |
|
169 else if( ECamSettingItemStaticVideoRangeMin < settingId |
|
170 && ECamSettingItemStaticVideoRangeMax > settingId ) |
|
171 { |
|
172 TInt settingIndex = SearchInSettingsListFor( iStaticVideoIntSettings, settingId ); |
|
173 iStaticVideoIntSettings[settingIndex]->iValueId = aSettingValue; |
|
174 SaveStaticSettingL( settingId ); |
|
175 |
|
176 // Video / photo storage settings follow eachother |
|
177 if ( ECamSettingItemVideoMediaStorage == settingId ) |
|
178 { |
|
179 TInt index = SearchInSettingsListFor( iStaticPhotoIntSettings, |
|
180 ECamSettingItemPhotoMediaStorage ); |
|
181 if ( index != KErrNotFound ) |
|
182 { |
|
183 iStaticPhotoIntSettings[index]->iValueId = aSettingValue; |
|
184 SaveStaticSettingL( ECamSettingItemPhotoMediaStorage ); |
|
185 } |
|
186 } |
|
187 } |
|
188 // ------------------------------------------------------- |
|
189 // Static common settings |
|
190 else if( ECamSettingItemStaticCommonRangeMin < settingId |
|
191 && ECamSettingItemStaticCommonRangeMax > settingId ) |
|
192 { |
|
193 TInt settingIndex = SearchInSettingsListFor( iStaticCommonIntSettings, settingId ); |
|
194 iStaticCommonIntSettings[settingIndex]->iValueId = aSettingValue; |
|
195 SaveStaticSettingL( settingId ); |
|
196 } |
|
197 // ------------------------------------------------------- |
|
198 else |
|
199 { |
|
200 // Ignored at the moment |
|
201 PRINT( _L("Camera <> Setting item not found !!!") ); |
|
202 } |
|
203 // ------------------------------------------------------- |
|
204 } |
|
205 |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CCamStaticSettingsModel::SetTextSettingValueL |
|
209 // Sets a new text value for the specified setting |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CCamStaticSettingsModel::SetTextSettingValueL( TInt aSettingItem, |
|
213 const TDesC& aSettingValue ) |
|
214 { |
|
215 switch ( aSettingItem ) |
|
216 { |
|
217 case ECamSettingItemPhotoNameBase: |
|
218 { |
|
219 iPhotoBaseName = aSettingValue; |
|
220 break; |
|
221 } |
|
222 case ECamSettingItemVideoNameBase: |
|
223 { |
|
224 iVideoBaseName = aSettingValue; |
|
225 break; |
|
226 } |
|
227 case ECamSettingItemDefaultAlbumName: |
|
228 { |
|
229 iDefaultAlbumName = aSettingValue; |
|
230 break; |
|
231 } |
|
232 default: |
|
233 { |
|
234 PRINT( _L("Camera <> CCamSettingsModel::ECamPanicUnknownSettingItem 4" )) |
|
235 CamPanic( ECamPanicUnknownSettingItem ); |
|
236 return; |
|
237 } |
|
238 } |
|
239 SaveStaticSettingL( static_cast<TCamSettingItemIds>(aSettingItem) ); |
|
240 } |
|
241 |
|
242 |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CCamStaticSettingsModel::TextSettingValue |
|
246 // Returns the current text value for the specified setting |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 TPtrC CCamStaticSettingsModel::TextSettingValue( TInt aSettingItem ) const |
|
250 { |
|
251 switch ( aSettingItem ) |
|
252 { |
|
253 case ECamSettingItemPhotoNameBase: return iPhotoBaseName; |
|
254 case ECamSettingItemVideoNameBase: return iVideoBaseName; |
|
255 case ECamSettingItemDefaultAlbumName: return iDefaultAlbumName; |
|
256 default: |
|
257 { |
|
258 PRINT( _L("Camera =><= CCamSettingsModel::TextSettingValue, PANIC!!!" ) ); |
|
259 CamPanic( ECamPanicUnknownSettingItem ); |
|
260 } |
|
261 } |
|
262 return NULL; |
|
263 } |
|
264 |
|
265 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
266 // --------------------------------------------------------------------------- |
|
267 // CCamStaticSettingsModel::LoadStaticSettingsL |
|
268 // Loads the static settings from shared data. Required to update |
|
269 // the settings whenever get foreground event, incase of external |
|
270 // changes to the settings. |
|
271 // Note that static settings cannot be loaded until the AppUi has been created, |
|
272 // as which settings to use is dependent on if app is embedded or not. |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 void CCamStaticSettingsModel::LoadStaticSettingsL( TBool aIsEmbedded ) |
|
276 { |
|
277 PRINT(_L("Camera => CCamStaticSettingsModel::LoadStaticSettingsL" )) |
|
278 iEmbedded = aIsEmbedded; |
|
279 |
|
280 // Free all memory currently used by the static settings. |
|
281 UnloadStaticSettings(); |
|
282 |
|
283 // Settings that depend on embedded status |
|
284 // If this application is embedded in MMS load |
|
285 // the embedded defaults for static settings. |
|
286 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
287 if ( iEmbedded ) |
|
288 { |
|
289 LoadEmbeddedSettingsL(); |
|
290 } |
|
291 #endif //CAMERAAPP_PLUGIN_BUILD |
|
292 |
|
293 // Settings that *do not* depend on embedded status |
|
294 LoadPhotoStaticSettingsL( EFalse ); |
|
295 LoadVideoStaticSettingsL( EFalse ); |
|
296 LoadCommonStaticSettingsL( EFalse ); |
|
297 |
|
298 PRINT(_L("Camera <= CCamSettingsModel::LoadStaticSettingsL" )) |
|
299 } |
|
300 |
|
301 #endif //#ifndef CAMERAAPP_PLUGIN_BUILD |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CCamStaticSettingsModel::ReadCenRepIntL |
|
305 // Reads the specified setting from Central Repository to the specified |
|
306 // settings model array |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CCamStaticSettingsModel::ReadFromCenRepL( const TInt aMinRange, |
|
310 const TInt aMaxRange, |
|
311 RPointerArray <TIntSetting>& aArray ) |
|
312 { |
|
313 TUint32 crKey; |
|
314 TBool ignore(EFalse); |
|
315 for ( TInt i = aMinRange+1; i < aMaxRange; i++ ) |
|
316 { |
|
317 ignore = EFalse; |
|
318 if ( i == ECamSettingItemPhotoNameBase ) |
|
319 { |
|
320 LoadPhotoBaseNameL(); |
|
321 } |
|
322 else if ( i == ECamSettingItemVideoNameBase ) |
|
323 { |
|
324 LoadVideoBaseNameL(); |
|
325 } |
|
326 else if ( i == ECamSettingItemDefaultAlbumName ) |
|
327 { |
|
328 LoadDefaultAlbumNameL(); |
|
329 } |
|
330 else |
|
331 { |
|
332 /* |
|
333 * Settings that depend on embedded status, we ignore reading the settings |
|
334 * if we are loading settings for embedded camera. |
|
335 */ |
|
336 if ( iEmbedded && |
|
337 ( i == ECamSettingItemPhotoQuality || |
|
338 i == ECamSettingItemShowCapturedPhoto || |
|
339 i == ECamSettingItemVideoQuality || |
|
340 i == ECamSettingItemVideoShowCapturedVideo || |
|
341 i == ECamSettingItemVideoAudioRec ) ) |
|
342 { |
|
343 ignore = ETrue; |
|
344 } |
|
345 if ( !ignore ) |
|
346 { |
|
347 crKey = MapSettingItem2CRKey( static_cast<TCamSettingItemIds>( i ), |
|
348 iEmbedded ); |
|
349 ReadCenRepIntL( static_cast<TCamSettingItemIds>( i ), |
|
350 crKey, |
|
351 aArray ); |
|
352 } |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 |
|
358 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
359 // --------------------------------------------------------------------------- |
|
360 // CCamStaticSettingsModel::LoadEmbeddedSettingsL(); |
|
361 // Reads the specified setting from Central Repository to the specified |
|
362 // settings model array |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 void CCamStaticSettingsModel::LoadEmbeddedSettingsL() |
|
366 { |
|
367 LoadSettingsFromResourceL( R_CAM_PHOTO_EMBEDDED_STATIC_SETTINGS_DATA, |
|
368 iStaticPhotoIntSettings ); |
|
369 LoadSettingsFromResourceL( R_CAM_VIDEO_EMBEDDED_STATIC_SETTINGS_DATA, |
|
370 iStaticVideoIntSettings ); |
|
371 |
|
372 // Video - Record Audio (not shared with standalone) |
|
373 ReadCenRepIntL( ECamSettingItemVideoAudioRec, |
|
374 KCamCrEmbeddedVideoAudRec, |
|
375 iStaticVideoIntSettings ); |
|
376 |
|
377 TIntSetting* newSetting = new (ELeave) TIntSetting; |
|
378 CleanupStack::PushL( newSetting ); |
|
379 |
|
380 // Read the data for this setting item from resource. |
|
381 newSetting->iItemId = ECamSettingItemPhotoQuality; |
|
382 |
|
383 CCamAppUiBase* appUi = 0; |
|
384 TSize requiredReso, requiredResolution; |
|
385 // if using the second camera |
|
386 if( static_cast<CCamAppUiBase*>( |
|
387 CEikonEnv::Static()->AppUi() )->ActiveCamera() == ECamActiveCameraSecondary ) |
|
388 { |
|
389 PRINT(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL Setting secondary camera image quality" )) |
|
390 newSetting->iValueId = iConfiguration.SecondaryCameraImageQuality(); |
|
391 } |
|
392 else |
|
393 { |
|
394 appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
395 requiredReso = appUi->RequestedNewFileResolution(); |
|
396 requiredResolution = iConfiguration.MapRequiredResolutionToActualResolutionPhoto(requiredReso); |
|
397 if ( requiredResolution == TSize(0,0) ) |
|
398 { |
|
399 PRINT(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL Setting mms image quality" )) |
|
400 newSetting->iValueId = iConfiguration.MmsImageQuality(); |
|
401 } |
|
402 else |
|
403 { |
|
404 PRINT(_L("Camera <=> CCamStaticSettingsModdel::LoadEmbeddedSettingsL Setting custom image quality")); |
|
405 TSize resolutionToGet = requiredResolution; |
|
406 PRINT2(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL image resolutionToGet(%d,%d)"), resolutionToGet.iWidth, resolutionToGet.iHeight ); |
|
407 TInt QualityIndex = iConfiguration.GetRequiredImageQualityIndex( resolutionToGet ); |
|
408 PRINT1(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL image QualityIndex: %d"), QualityIndex ); |
|
409 newSetting->iValueId = iConfiguration.ImageQuality( QualityIndex ).iPhotoQualityId; |
|
410 PRINT1(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL image newSetting->iValueId: %d"), newSetting->iValueId ); |
|
411 } |
|
412 } |
|
413 |
|
414 // Add the new setting item and its associated key |
|
415 // to the parallel arrays for static photo settings. |
|
416 iStaticPhotoIntSettings.AppendL( newSetting ); |
|
417 CleanupStack::Pop( newSetting ); |
|
418 |
|
419 newSetting = new (ELeave) TIntSetting; |
|
420 CleanupStack::PushL( newSetting ); |
|
421 |
|
422 // Read the data for this setting item from resource. |
|
423 newSetting->iItemId = ECamSettingItemVideoQuality; |
|
424 |
|
425 // if using the second camera |
|
426 if( static_cast<CCamAppUiBase*>( |
|
427 CEikonEnv::Static()->AppUi() )->ActiveCamera() == ECamActiveCameraSecondary ) |
|
428 { |
|
429 PRINT(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL Setting secondary camera image quality" )) |
|
430 newSetting->iValueId = iConfiguration.SecondaryCameraVideoQuality(); |
|
431 } |
|
432 else |
|
433 { |
|
434 appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
435 requiredReso = appUi->RequestedNewFileResolution(); |
|
436 requiredResolution = iConfiguration.MapRequiredResolutionToActualResolutionVideo(requiredReso); |
|
437 if ( requiredResolution == TSize(0,0) ) |
|
438 { |
|
439 PRINT(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL Setting mms video quality" )) |
|
440 newSetting->iValueId = iConfiguration.SecondaryCameraVideoQuality(); |
|
441 } |
|
442 else |
|
443 { |
|
444 TSize resolutionToGet = requiredResolution; |
|
445 PRINT2(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL resolutionToGet(%d,%d)"), resolutionToGet.iWidth, resolutionToGet.iHeight ); |
|
446 TInt QualityIndex = iConfiguration.GetRequiredVideoQualityIndex( resolutionToGet ); |
|
447 PRINT1(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL QualityIndex: %d"), QualityIndex ); |
|
448 newSetting->iValueId = iConfiguration.VideoQualitySetting( QualityIndex ); |
|
449 PRINT1(_L("Camera <=> CCamStaticSettingsModel::LoadEmbeddedSettingsL newSetting->iValueId: %d"), newSetting->iValueId ); |
|
450 } |
|
451 } |
|
452 |
|
453 // Add the new setting item and its associated key |
|
454 // to the parallel arrays for static photo settings. |
|
455 iStaticVideoIntSettings.AppendL( newSetting ); |
|
456 CleanupStack::Pop( newSetting ); |
|
457 } |
|
458 |
|
459 #endif //CAMERAAPP_PLUGIN_BUILD |
|
460 |
|
461 // --------------------------------------------------------------------------- |
|
462 // CCamStaticSettingsModel::ReadCenRepIntL |
|
463 // Reads the specified setting from Central Repository to the specified |
|
464 // settings model array |
|
465 // --------------------------------------------------------------------------- |
|
466 // |
|
467 void CCamStaticSettingsModel::ReadCenRepIntL( TCamSettingItemIds aUiId, |
|
468 TInt aCenRepID, |
|
469 RPointerArray <TIntSetting>& aArray ) |
|
470 { |
|
471 PRINT2(_L("Camera => CCamStaticSettingsModel::ReadCenRepIntL set id:%d, cenrep id: 0x%02X" ), aUiId, aCenRepID ) |
|
472 TIntSetting* newSetting = new( ELeave ) TIntSetting; |
|
473 CleanupStack::PushL( newSetting ); |
|
474 newSetting->iItemId = aUiId; |
|
475 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
476 // if using the second camera, then get the photo\video quality from |
|
477 // the cached value, not the shared data file |
|
478 if( ( aUiId == ECamSettingItemPhotoQuality || |
|
479 aUiId == ECamSettingItemVideoQuality ) && |
|
480 static_cast<CCamAppUiBase*>( |
|
481 CEikonEnv::Static()->AppUi() )->ActiveCamera() == ECamActiveCameraSecondary ) |
|
482 { |
|
483 if ( aUiId == ECamSettingItemPhotoQuality ) |
|
484 { |
|
485 newSetting->iValueId = iSecondaryCameraSettings.iPhotoQuality; |
|
486 } |
|
487 else |
|
488 { |
|
489 newSetting->iValueId = iSecondaryCameraSettings.iVideoQuality; |
|
490 } |
|
491 } |
|
492 else // get the value from the shared data file |
|
493 #endif //CAMERAAPP_PLUGIN_BUILD |
|
494 { |
|
495 User::LeaveIfError( iRepository->Get( aCenRepID , newSetting->iValueId ) ); |
|
496 |
|
497 // When getting the default video qulity, should get the default setting |
|
498 // from ICM |
|
499 if(aUiId == ECamSettingItemVideoQuality && |
|
500 newSetting->iValueId == KCamUseDefaultVideoQuality) |
|
501 { |
|
502 newSetting->iValueId = iConfiguration.GetDefaultVideoQualityFromIcmL(); |
|
503 } |
|
504 } |
|
505 |
|
506 aArray.AppendL( newSetting ); |
|
507 CleanupStack::Pop( newSetting ); |
|
508 PRINT(_L("Camera <= CCamStaticSettingsModel::ReadCenRepIntL" )) |
|
509 } |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CCamStaticSettingsModel::SaveCenRepItemL |
|
513 // Writes the specified setting to the Central Repository |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 void |
|
517 CCamStaticSettingsModel::SaveCenRepItemL( |
|
518 TCamSettingItemIds aItemId, |
|
519 TInt aCenRepId, |
|
520 const RPointerArray<TIntSetting>& aArray ) |
|
521 { |
|
522 PRINT( _L("Camera => CCamStaticSettingsModel::SaveCenRepItemL") ); |
|
523 TInt settingIndex = SearchInSettingsListFor( aArray, aItemId ); |
|
524 |
|
525 if ( settingIndex != KErrNotFound ) |
|
526 { |
|
527 TInt settingValue = aArray[ settingIndex ]->iValueId; |
|
528 User::LeaveIfError( iRepository->Set( aCenRepId, settingValue ) ); |
|
529 } |
|
530 else |
|
531 { |
|
532 User::Leave( settingIndex ); |
|
533 } |
|
534 PRINT( _L("Camera <= CCamStaticSettingsModel::SaveCenRepItemL") ); |
|
535 } |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // CCamStaticSettingsModel::SaveSettingsL |
|
539 // Saves the static settings to the shared data ini file |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void CCamStaticSettingsModel::SaveSettingsL() |
|
543 { |
|
544 // do nothing, from now whenever a setting is changed, |
|
545 // we call savestaticsettingL. |
|
546 } |
|
547 |
|
548 |
|
549 // -------------------------------------------- |
|
550 // CCamStaticSettingsModel::SaveStaticSettingL |
|
551 // -------------------------------------------- |
|
552 // |
|
553 void |
|
554 CCamStaticSettingsModel::SaveStaticSettingL( TCamSettingItemIds aSettingId ) |
|
555 { |
|
556 PRINT( _L("CCamStaticSettingsModel => SaveStaticSettingL") ); |
|
557 |
|
558 switch( aSettingId ) |
|
559 { |
|
560 // Special cases for text settings. |
|
561 // KCamCrLastUsedMonthFolder is also in text form, but it cannot be accessed |
|
562 // with a setting item id. |
|
563 case ECamSettingItemPhotoNameBase: SavePhotoBaseNameL(); break; |
|
564 case ECamSettingItemVideoNameBase: SaveVideoBaseNameL(); break; |
|
565 case ECamSettingItemDefaultAlbumName: SaveDefaultAlbumNameL(); break; |
|
566 |
|
567 // Only save photo and video quality for primary camera |
|
568 case ECamSettingItemPhotoQuality: |
|
569 { |
|
570 if ( !iEmbedded ) |
|
571 { |
|
572 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
573 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
574 if ( appUi->ActiveCamera() == ECamActiveCameraPrimary ) |
|
575 #endif //CAMERAAPP_PLUGIN_BUILD |
|
576 { |
|
577 SaveCenRepItemL( ECamSettingItemPhotoQuality, |
|
578 KCamCrPhotoQuality, |
|
579 iStaticPhotoIntSettings ); |
|
580 } |
|
581 } |
|
582 break; |
|
583 } |
|
584 case ECamSettingItemVideoQuality: |
|
585 { |
|
586 if ( !iEmbedded ) |
|
587 { |
|
588 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
589 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
590 if ( appUi->ActiveCamera() == ECamActiveCameraPrimary ) |
|
591 #endif //CAMERAAPP_PLUGIN_BUILD |
|
592 { |
|
593 SaveCenRepItemL( ECamSettingItemVideoQuality, |
|
594 KCamCrVideoQuality, |
|
595 iStaticVideoIntSettings ); |
|
596 } |
|
597 } |
|
598 break; |
|
599 } |
|
600 // Text settings which require no special handling |
|
601 case ECamSettingItemImageToolbarItems: |
|
602 case ECamSettingItemImageToolbarDefaultItems: |
|
603 { |
|
604 TUint32 crKey = MapSettingItem2CRKey( aSettingId, iEmbedded ); |
|
605 TPtrC value = TextSettingValue( aSettingId ); |
|
606 |
|
607 User::LeaveIfError( iRepository->Set( crKey, value ) ); |
|
608 break; |
|
609 } |
|
610 case ECamSettingItemShowCapturedPhoto: |
|
611 case ECamSettingItemVideoShowCapturedVideo: |
|
612 { |
|
613 if ( iEmbedded ) |
|
614 { |
|
615 // if in the embedded mode, we dont save value to the CenRep |
|
616 // because in Embedded mode show photo/video capture setting is |
|
617 // always on. |
|
618 return; |
|
619 } |
|
620 else |
|
621 { |
|
622 } |
|
623 } |
|
624 // Integer settings which require no special handling |
|
625 default: |
|
626 { |
|
627 RPointerArray<TIntSetting>* settingArray = |
|
628 MapSettingItem2SettingsList( aSettingId ); |
|
629 |
|
630 if( settingArray ) |
|
631 { |
|
632 TUint32 crKey = MapSettingItem2CRKey( aSettingId, iEmbedded ); |
|
633 SaveCenRepItemL( aSettingId, crKey, *settingArray ); |
|
634 } |
|
635 else |
|
636 { |
|
637 CamPanic( ECamPanicUnknownSettingItem ); |
|
638 } |
|
639 break; |
|
640 } |
|
641 } // switch |
|
642 |
|
643 PRINT( _L("CCamStaticSettingsModel <= SaveStaticSettingL") ); |
|
644 } |
|
645 |
|
646 |
|
647 // --------------------------------------------------------------------------- |
|
648 // MapSettingItem2CRKey <<static>> |
|
649 // --------------------------------------------------------------------------- |
|
650 // |
|
651 TUint32 |
|
652 CCamStaticSettingsModel::MapSettingItem2CRKey( TCamSettingItemIds aSettingId, |
|
653 TBool aEmbedded ) |
|
654 { |
|
655 PRINT( _L("Camera => CCamStaticSettingsModel::MapSettingItem2CRKey") ); |
|
656 TUint32 crKey( 0 ); |
|
657 |
|
658 // ------------------------------------------------------- |
|
659 // static photo settings |
|
660 if( ECamSettingItemStaticPhotoRangeMin < aSettingId |
|
661 && ECamSettingItemStaticPhotoRangeMax > aSettingId ) |
|
662 { |
|
663 PRINT( _L(" Camera <=> CCamStaticSettingsModel ECamSettingItemStaticPhoto") ); |
|
664 switch( aSettingId ) |
|
665 { |
|
666 case ECamSettingItemPhotoQuality: crKey = KCamCrPhotoQuality; break; |
|
667 case ECamSettingItemPhotoSize: crKey = KCamCrPhotoSize; break; |
|
668 case ECamSettingItemPhotoShowFocusPoint: crKey = KCamCrFocusPoint; break; |
|
669 case ECamSettingItemPhotoStoreInAlbum: crKey = KCamCrPhotoStoreAlbum; break; //KCamCrDefaultAlbumId |
|
670 case ECamSettingItemShowCapturedPhoto: crKey = KCamCrPhotoShowCaptured; break; |
|
671 case ECamSettingItemPhotoCaptureTone: crKey = KCamCrPhotoCaptureTone; break; |
|
672 case ECamSettingItemFaceTracking: crKey = KCamCrPhotoFaceTracking; break; |
|
673 case ECamSettingItemPhotoMediaStorage: crKey = KCamCrPhotoMemInUse; break; |
|
674 case ECamSettingItemPhotoNameBase: crKey = KCamCrPhotoNameBase; break; |
|
675 |
|
676 case ECamSettingItemPhotoNameBaseType: crKey = KCamCrPhotoNameType; break; |
|
677 case ECamSettingItemPhotoNumber: crKey = KCamCrPhotoImgCount; break; |
|
678 case ECamSettingItemPhotoDigitalZoom: crKey = KCamCrPhotoExtDigZoom; break; |
|
679 case ECamSettingItemImageRotation: crKey = KCamCrPhotoRotation; break; |
|
680 case ECamSettingItemFlickerCancel: crKey = KCamCrFlickerCancellation; break; |
|
681 |
|
682 case ECamSettingItemImageToolbarItems: crKey = KCamCrImageToolbarItems; break; |
|
683 case ECamSettingItemImageToolbarDefaultItems: crKey = KCamCrImageToolbarDefaultItems; break; |
|
684 case ECamSettingItemContinuousAutofocus: |
|
685 crKey = KCamCrContinuousAutofocus; |
|
686 break; |
|
687 |
|
688 default: CamPanic( ECamPanicUnknownSettingItem ); |
|
689 break; |
|
690 } |
|
691 } |
|
692 // ------------------------------------------------------- |
|
693 // static video settings |
|
694 else if( ECamSettingItemStaticVideoRangeMin < aSettingId |
|
695 && ECamSettingItemStaticVideoRangeMax > aSettingId ) |
|
696 { |
|
697 PRINT( _L(" Camera <=> CCamStaticSettingsModel : ECamSettingItemStaticVideoRange") ); |
|
698 switch( aSettingId ) |
|
699 { |
|
700 case ECamSettingItemVideoAudioRec: |
|
701 if( aEmbedded ) crKey = KCamCrEmbeddedVideoAudRec; |
|
702 else crKey = KCamCrVideoAudRec; |
|
703 break; |
|
704 case ECamSettingItemContinuousAutofocus: |
|
705 crKey = KCamCrContinuousAutofocus; |
|
706 break; |
|
707 case ECamSettingItemVideoResolution: crKey = KCamCrVideoRes; break; |
|
708 case ECamSettingItemVideoClipLength: crKey = KCamCrVideoClipLen; break; |
|
709 case ECamSettingItemVideoFileType: crKey = KCamCrVideoFileType; break; |
|
710 case ECamSettingItemVideoStoreInAlbum: crKey = KCamCrVideoStoreAlbum; break; //KCamCrDefaultAlbumId |
|
711 case ECamSettingItemVideoShowCapturedVideo: crKey = KCamCrVideoShowCaptured; break; |
|
712 case ECamSettingItemVideoMediaStorage: crKey = KCamCrVideoMemInUse; break; |
|
713 case ECamSettingItemVideoNameBase: crKey = KCamCrVideoNameBase; break; |
|
714 case ECamSettingItemVideoNameBaseType: crKey = KCamCrVideoNameType; break; |
|
715 case ECamSettingItemVideoNumber: crKey = KCamCrVideoCount; break; |
|
716 case ECamSettingItemVideoQuality: crKey = KCamCrVideoQuality; break; |
|
717 case ECamSettingItemVideoDigitalZoom: crKey = KCamCrVideoExtDigZoom; break; |
|
718 case ECamSettingItemVideoStab: crKey = KCamCrVideoStabilisation; break; |
|
719 default: CamPanic( ECamPanicUnknownSettingItem ); |
|
720 break; |
|
721 } |
|
722 } |
|
723 // ------------------------------------------------------- |
|
724 // static common settings |
|
725 else if( ECamSettingItemStaticCommonRangeMin < aSettingId |
|
726 && ECamSettingItemStaticCommonRangeMax > aSettingId ) |
|
727 { |
|
728 PRINT( _L("Camera <=> CCamStaticSettingsModel ECamSettingItemStaticCommon") ); |
|
729 switch( aSettingId ) |
|
730 { |
|
731 case ECamSettingItemUserMode: crKey = KCamCrUserMode; break; |
|
732 case ECamSettingItemDefaultAlbumId: crKey = KCamCrDefaultAlbumId; break; |
|
733 case ECamSettingItemDefaultAlbumName: crKey = KCamCrDefaultAlbumTitle; break; |
|
734 case ECamSettingItemRecLocation: crKey = KCamCrPhotoStoreLocation; break; |
|
735 default: CamPanic( ECamPanicUnknownSettingItem ); |
|
736 break; |
|
737 } |
|
738 } |
|
739 // ------------------------------------------------------- |
|
740 else if( ECamSettingItemUserSceneRangeMin < aSettingId |
|
741 && ECamSettingItemUserSceneRangeMax > aSettingId ) |
|
742 { |
|
743 PRINT( _L("Camera <=> CCamStaticSettingsModel ECamSettingItemUserSceneRange") ); |
|
744 switch( aSettingId ) |
|
745 { |
|
746 case ECamSettingItemUserSceneBasedOnScene: crKey = KCamCrUserSceneBaseScene; break; |
|
747 case ECamSettingItemUserSceneWhitebalance: crKey = KCamCrUserSceneWhiteBalance; break; |
|
748 case ECamSettingItemUserSceneColourFilter: crKey = KCamCrUserSceneColourFilter; break; |
|
749 case ECamSettingItemUserSceneExposure: crKey = KCamCrUserSceneExposure; break; |
|
750 case ECamSettingItemUserSceneFlash: crKey = KCamCrUserSceneFlash; break; |
|
751 case ECamSettingItemUserSceneBrightness: crKey = KCamCrUserSceneBrightness; break; |
|
752 case ECamSettingItemUserSceneContrast: crKey = KCamCrUserSceneContrast; break; |
|
753 case ECamSettingItemUserSceneImageSharpness: crKey = KCamCrUserSceneImageSharpness; break; |
|
754 case ECamSettingItemUserSceneColourSaturation: crKey = KCamCrUserSceneColourSaturation; break; |
|
755 case ECamSettingItemUserSceneLightSensitivity: crKey = KCamCrUserSceneLightSensitivity; break; |
|
756 default: CamPanic( ECamPanicUnknownSettingItem ); |
|
757 break; |
|
758 } |
|
759 } |
|
760 else |
|
761 { |
|
762 PRINT( _L(" Camera <=> CCamStaticSettingsModel CamPanic( ECamPanicUnknownSettingItem )") ); |
|
763 CamPanic( ECamPanicUnknownSettingItem ); |
|
764 } |
|
765 |
|
766 PRINT( _L("Camera <= CCamSettingsModel::MapSettingItem2CRKey") ); |
|
767 return crKey; |
|
768 } |
|
769 |
|
770 // --------------------------------------------------------------------------- |
|
771 // |
|
772 // --------------------------------------------------------------------------- |
|
773 // |
|
774 RPointerArray<TIntSetting>* |
|
775 CCamStaticSettingsModel::MapSettingItem2SettingsList( TCamSettingItemIds aSettingId ) |
|
776 { |
|
777 PRINT( _L("Camera => CCamStaticSettingsModel::MapSettingItem2SettingsList") ); |
|
778 |
|
779 RPointerArray<TIntSetting>* array( NULL ); |
|
780 |
|
781 if( ECamSettingItemStaticPhotoRangeMin < aSettingId && |
|
782 ECamSettingItemStaticPhotoRangeMax > aSettingId ) |
|
783 { |
|
784 if( ECamSettingItemPhotoNameBase == aSettingId ) |
|
785 array = NULL; |
|
786 else |
|
787 array = &iStaticPhotoIntSettings; |
|
788 } |
|
789 else if( ECamSettingItemStaticVideoRangeMin < aSettingId && |
|
790 ECamSettingItemStaticVideoRangeMax > aSettingId ) |
|
791 { |
|
792 if( ECamSettingItemVideoNameBase == aSettingId ) |
|
793 array = NULL; |
|
794 else |
|
795 array = &iStaticVideoIntSettings; |
|
796 } |
|
797 else if( ECamSettingItemStaticCommonRangeMin < aSettingId && |
|
798 ECamSettingItemStaticCommonRangeMax > aSettingId ) |
|
799 { |
|
800 array = &iStaticCommonIntSettings; |
|
801 } |
|
802 else |
|
803 { |
|
804 CamPanic( ECamPanicUnknownSettingItem ); |
|
805 array = NULL; |
|
806 } |
|
807 |
|
808 PRINT( _L("Camera <= CCamStaticSettingsModel::MapSettingItem2SettingsList") ); |
|
809 return array; |
|
810 } |
|
811 |
|
812 |
|
813 // --------------------------------------------------------------------------- |
|
814 // CCamStaticSettingsModel::~CCamStaticSettingsModel |
|
815 // Destructor |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 CCamStaticSettingsModel::~CCamStaticSettingsModel() |
|
819 { |
|
820 PRINT( _L("Camera => ~CCamStaticSettingsModel") ); |
|
821 iStaticCommonIntSettings.ResetAndDestroy(); |
|
822 iStaticCommonIntSettings.Close(); |
|
823 |
|
824 iStaticPhotoIntSettings.ResetAndDestroy(); |
|
825 iStaticPhotoIntSettings.Close(); |
|
826 |
|
827 iStaticVideoIntSettings.ResetAndDestroy(); |
|
828 iStaticVideoIntSettings.Close(); |
|
829 delete iRepository; |
|
830 delete iConfigManager; |
|
831 iConfigManager = NULL; |
|
832 PRINT( _L("Camera <= ~CCamStaticSettingsModel") ); |
|
833 } |
|
834 |
|
835 |
|
836 // --------------------------------------------------------------------------- |
|
837 // CCamStaticSettingsModel::CCamStaticSettingsModel |
|
838 // C++ constructor |
|
839 // --------------------------------------------------------------------------- |
|
840 // |
|
841 CCamStaticSettingsModel::CCamStaticSettingsModel( CCamConfiguration& aConfiguration ) |
|
842 : iEmbedded( EFalse ), |
|
843 iConfiguration( aConfiguration ) |
|
844 { |
|
845 iSecondaryCameraSettings.iVideoQuality |
|
846 = iConfiguration.SecondaryCameraVideoQuality(); |
|
847 iSecondaryCameraSettings.iPhotoQuality |
|
848 = iConfiguration.SecondaryCameraImageQuality(); |
|
849 |
|
850 // Check that configuration can provide us secondary camera qualities |
|
851 // If either of them is unavailable, all we can do is panic |
|
852 PRINT( _L("Camera <> Checking secondary camera qualities") ); |
|
853 __ASSERT_ALWAYS( iSecondaryCameraSettings.iVideoQuality > 0, |
|
854 CamPanic( ECamPanicSecondaryQualityMissing ) ); |
|
855 |
|
856 __ASSERT_ALWAYS( iSecondaryCameraSettings.iPhotoQuality > 0, |
|
857 CamPanic( ECamPanicSecondaryQualityMissing ) ); |
|
858 } |
|
859 |
|
860 |
|
861 // --------------------------------------------------------------------------- |
|
862 // CCamStaticSettingsModel::ConstructL |
|
863 // Symbian OS 2nd phase constructor |
|
864 // --------------------------------------------------------------------------- |
|
865 // |
|
866 void CCamStaticSettingsModel::ConstructL() |
|
867 { |
|
868 PRINT( _L("Camera => CCamStaticSettingsModel::ConstructL") ); |
|
869 iRepository = CRepository::NewL( KCRUidCameraappSettings ); |
|
870 iConfigManager = CCameraUiConfigManager::NewL(); |
|
871 PRINT( _L("Camera <= CCamStaticSettingsModel::ConstructL") ); |
|
872 } |
|
873 |
|
874 |
|
875 // --------------------------------------------------------------------------- |
|
876 // CCamStaticSettingsModel::SearchInSettingsListFor |
|
877 // Searches in a settings list for a particular setting item. |
|
878 // --------------------------------------------------------------------------- |
|
879 // |
|
880 TInt |
|
881 CCamStaticSettingsModel::SearchInSettingsListFor( |
|
882 const RPointerArray<TIntSetting>& aSettingsList, |
|
883 TInt aSettingItem ) const |
|
884 { |
|
885 return aSettingsList.Find( aSettingItem, SettingIdMatches ); |
|
886 } |
|
887 |
|
888 // --------------------------------------------------------------------------- |
|
889 // CCamStaticSettingsModel::ResetRepository |
|
890 // Reset Camera central repository file |
|
891 // --------------------------------------------------------------------------- |
|
892 // |
|
893 void CCamStaticSettingsModel::ResetRepository() |
|
894 { |
|
895 if( iRepository ) |
|
896 { |
|
897 iRepository->Reset(); |
|
898 } |
|
899 } |
|
900 |
|
901 |
|
902 // --------------------------------------------------------------------------- |
|
903 // CCamStaticSettingsModel::UnloadStaticSettings |
|
904 // Remove any previously loaded static settings. |
|
905 // --------------------------------------------------------------------------- |
|
906 // |
|
907 void CCamStaticSettingsModel::UnloadStaticSettings() |
|
908 { |
|
909 PRINT( _L("Camera => CCamStaticSettingsModel::UnloadStaticSettings()" )) |
|
910 iStaticCommonIntSettings.ResetAndDestroy(); |
|
911 iStaticPhotoIntSettings.ResetAndDestroy(); |
|
912 iStaticVideoIntSettings.ResetAndDestroy(); |
|
913 PRINT( _L("Camera <= CCamStaticSettingsModel::UnloadStaticSettings()" )) |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // CCamStaticSettingsModel::LoadPhotoBaseNameL |
|
918 // Loads the photo base name either from resource or from shared data |
|
919 // as appropriate |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 void |
|
923 CCamStaticSettingsModel::LoadPhotoBaseNameL() |
|
924 { |
|
925 User::LeaveIfError( iRepository->Get( KCamCrPhotoNameBase , iPhotoBaseName ) ); |
|
926 // If photoname base not defined |
|
927 if ( iPhotoBaseName.Length() == 0 ) |
|
928 { |
|
929 // Read base file name from resources and set the shared data key. |
|
930 StringLoader::Load( iPhotoBaseName, R_CAM_NAMEBASE_IMAGE ); |
|
931 } |
|
932 } |
|
933 |
|
934 // |
|
935 // --------------------------------------------------------------------------- |
|
936 // CCamStaticSettingsModel::LoadVideoBaseNameL |
|
937 // Loads the video base name either from resource or from shared data |
|
938 // as appropriate |
|
939 // --------------------------------------------------------------------------- |
|
940 void |
|
941 CCamStaticSettingsModel::LoadVideoBaseNameL() |
|
942 { |
|
943 User::LeaveIfError( iRepository->Get( KCamCrVideoNameBase , iVideoBaseName ) ); |
|
944 if ( iVideoBaseName.Length() == 0 ) |
|
945 { |
|
946 // Read base file name from resources and set the shared data key. |
|
947 StringLoader::Load( iVideoBaseName, R_CAM_NAMEBASE_VIDEO ); |
|
948 } |
|
949 } |
|
950 |
|
951 |
|
952 // |
|
953 // --------------------------------------------------------------------------- |
|
954 // CCamStaticSettingsModel::LoadVideoBaseNameL |
|
955 // Loads the video base name either from resource or from shared data |
|
956 // as appropriate |
|
957 // --------------------------------------------------------------------------- |
|
958 void |
|
959 CCamStaticSettingsModel::LoadDefaultAlbumNameL() |
|
960 { |
|
961 User::LeaveIfError( iRepository->Get( KCamCrDefaultAlbumTitle, |
|
962 iDefaultAlbumName ) ); |
|
963 } |
|
964 |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // CCamStaticSettingsModel::SavePhotoBaseNameL |
|
968 // Saves the photo base name after comparing against resource to see if we |
|
969 // have switched back to the default base |
|
970 // --------------------------------------------------------------------------- |
|
971 // |
|
972 void |
|
973 CCamStaticSettingsModel::SavePhotoBaseNameL() |
|
974 { |
|
975 TBuf<KMaxNameBaseLength> savedBaseName; |
|
976 TBuf<KMaxNameBaseLength> resourceBaseName; |
|
977 TBuf<KMaxNameBaseLength> sharedDataBaseName = iPhotoBaseName; |
|
978 |
|
979 User::LeaveIfError( iRepository->Get( KCamCrPhotoNameBase, |
|
980 savedBaseName ) ); |
|
981 StringLoader::Load(resourceBaseName, R_CAM_NAMEBASE_IMAGE ); |
|
982 |
|
983 if ( savedBaseName.Length() == 0 && iPhotoBaseName == resourceBaseName ) |
|
984 { |
|
985 sharedDataBaseName = KNullDesC; |
|
986 } |
|
987 User::LeaveIfError( iRepository->Set( KCamCrPhotoNameBase, |
|
988 sharedDataBaseName ) ); |
|
989 } |
|
990 |
|
991 // |
|
992 // --------------------------------------------------------------------------- |
|
993 // CCamStaticSettingsModel::SaveVideoBaseNameL |
|
994 // Saves the video base name after comparing against resource to see if we |
|
995 // have switched back to the default base |
|
996 // --------------------------------------------------------------------------- |
|
997 void CCamStaticSettingsModel::SaveVideoBaseNameL() |
|
998 { |
|
999 TBuf<KMaxNameBaseLength> savedBaseName; |
|
1000 TBuf<KMaxNameBaseLength> resourceBaseName; |
|
1001 TBuf<KMaxNameBaseLength> sharedDataBaseName = iVideoBaseName; |
|
1002 |
|
1003 User::LeaveIfError( iRepository->Get( KCamCrVideoNameBase, |
|
1004 savedBaseName ) ); |
|
1005 StringLoader::Load(resourceBaseName, R_CAM_NAMEBASE_VIDEO ); |
|
1006 |
|
1007 if ( savedBaseName.Length() == 0 && |
|
1008 iVideoBaseName == resourceBaseName ) |
|
1009 { |
|
1010 sharedDataBaseName = KNullDesC; |
|
1011 } |
|
1012 |
|
1013 User::LeaveIfError( iRepository->Set( KCamCrVideoNameBase, |
|
1014 sharedDataBaseName ) ); |
|
1015 } |
|
1016 |
|
1017 |
|
1018 // |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // CCamStaticSettingsModel::SaveDefaultAlbumNameL |
|
1021 // Saves the name of the default album set |
|
1022 // --------------------------------------------------------------------------- |
|
1023 void CCamStaticSettingsModel::SaveDefaultAlbumNameL() |
|
1024 { |
|
1025 User::LeaveIfError( iRepository->Set( KCamCrDefaultAlbumTitle, |
|
1026 iDefaultAlbumName ) ); |
|
1027 } |
|
1028 |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // CCamStaticSettingsModel::ReadCenRepStringL |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 HBufC* |
|
1035 CCamStaticSettingsModel::ReadCenRepStringL( TInt aCenRepKeyId ) |
|
1036 { |
|
1037 PRINT1( _L("Camera => CCamSettingsModel::ReadCenRepStringL, key:0x%02x"), aCenRepKeyId ); |
|
1038 |
|
1039 HBufC* string = HBufC::NewLC( KCamCRStringInitialLength ); |
|
1040 |
|
1041 TPtr ptr = string->Des(); |
|
1042 TInt size = 0; |
|
1043 TInt status = iRepository->Get( aCenRepKeyId, ptr, size ); |
|
1044 |
|
1045 // Did not fit into the string, reserve more memory and try again |
|
1046 if( KErrOverflow == status ) |
|
1047 { |
|
1048 PRINT2( _L("Camera <> CCamSettingsModel: need bigger buffer, length: %d -> %d"), ptr.MaxLength(), size ); |
|
1049 CleanupStack::PopAndDestroy(); // String |
|
1050 string = HBufC::NewLC( size ); |
|
1051 ptr = string->Des(); |
|
1052 |
|
1053 status = iRepository->Get( aCenRepKeyId, ptr, size ); |
|
1054 } |
|
1055 |
|
1056 User::LeaveIfError( status ); |
|
1057 CleanupStack::Pop(); // string |
|
1058 PRINT1( _L("Camera <= CCamSettingsModel::ReadCenRepStringL, got string:[%S]"), string); |
|
1059 |
|
1060 return string; |
|
1061 } |
|
1062 |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // CCamStaticSettingsModel::ResetSettingItem |
|
1065 // --------------------------------------------------------------------------- |
|
1066 // |
|
1067 void CCamStaticSettingsModel::ResetSettingItem( const TInt aCenRepKeyId ) |
|
1068 { |
|
1069 TInt err = iRepository->Reset( aCenRepKeyId ); |
|
1070 if ( KErrNone != err ) |
|
1071 { |
|
1072 // Handle the error case |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 |
|
1077 // --------------------------------------------------------------------------- |
|
1078 // CCamSettingsModel::StorePrimaryCameraSettingsL |
|
1079 // Stores the primary camera settings so they can be reapplied when |
|
1080 // changing from front to back camera |
|
1081 // --------------------------------------------------------------------------- |
|
1082 // |
|
1083 void CCamStaticSettingsModel::StorePrimaryCameraSettingsL() |
|
1084 { |
|
1085 PRINT( _L("Camera => CCamStaticSettingsModel::StorePrimaryCameraSettingsL")) |
|
1086 TInt settingIndex = SearchInSettingsListFor( iStaticPhotoIntSettings, |
|
1087 ECamSettingItemPhotoQuality ); |
|
1088 if ( settingIndex != KErrNotFound ) |
|
1089 { |
|
1090 iPrimaryCameraSettings.iPhotoQuality = |
|
1091 iStaticPhotoIntSettings[settingIndex]->iValueId; |
|
1092 } |
|
1093 |
|
1094 settingIndex = SearchInSettingsListFor( iStaticVideoIntSettings, |
|
1095 ECamSettingItemVideoQuality ); |
|
1096 if ( settingIndex != KErrNotFound ) |
|
1097 { |
|
1098 iPrimaryCameraSettings.iVideoQuality = |
|
1099 iStaticVideoIntSettings[settingIndex]->iValueId; |
|
1100 } |
|
1101 PRINT( _L("Camera <= CCamStaticSettingsModel::StorePrimaryCameraSettingsL")) |
|
1102 } |
|
1103 |
|
1104 // --------------------------------------------------------------------------- |
|
1105 // CCamSettingsModel::RestorePrimaryCameraSettingsL |
|
1106 // Restores the primary camera settings when |
|
1107 // changing from front to back camera |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // |
|
1110 void CCamStaticSettingsModel::RestorePrimaryCameraSettingsL() |
|
1111 { |
|
1112 // set the stored primary camera settings |
|
1113 SetIntegerSettingValueL( ECamSettingItemPhotoQuality, |
|
1114 iPrimaryCameraSettings.iPhotoQuality ); |
|
1115 SetIntegerSettingValueL( ECamSettingItemVideoQuality, |
|
1116 iPrimaryCameraSettings.iVideoQuality ); |
|
1117 // set the secondary camera settings back to defaults |
|
1118 iSecondaryCameraSettings.iPhotoQuality = iConfiguration.SecondaryCameraImageQuality(); |
|
1119 iSecondaryCameraSettings.iVideoQuality = iConfiguration.SecondaryCameraVideoQuality(); |
|
1120 } |
|
1121 |
|
1122 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
1123 // --------------------------------------------------------------------------- |
|
1124 // CCamStaticSettingsModel::LoadDynamicSettingsL |
|
1125 // Loads the dynamic settings from resource file for a |
|
1126 // particular group of settings. |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // |
|
1129 void |
|
1130 CCamStaticSettingsModel::LoadSettingsFromResourceL( |
|
1131 TInt aResourceId, |
|
1132 RPointerArray<TIntSetting>& aSettingsList ) |
|
1133 { |
|
1134 // Create resource reader for reading photo static settings |
|
1135 TResourceReader reader; |
|
1136 CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
1137 TInt count = reader.ReadInt16(); |
|
1138 |
|
1139 // for each entry in the resource, create a new setting item. |
|
1140 TInt i; |
|
1141 for ( i = 0; i < count; ++i ) |
|
1142 { |
|
1143 TIntSetting* newSetting = new (ELeave) TIntSetting; |
|
1144 CleanupStack::PushL( newSetting ); |
|
1145 |
|
1146 // Read the data for this setting item from resource. |
|
1147 newSetting->iItemId = reader.ReadInt16(); |
|
1148 newSetting->iValueId = reader.ReadInt16(); |
|
1149 |
|
1150 // Add the new setting item and its associated key |
|
1151 // to the parallel arrays for static photo settings. |
|
1152 aSettingsList.AppendL( newSetting ); |
|
1153 CleanupStack::Pop( newSetting ); |
|
1154 } |
|
1155 |
|
1156 CleanupStack::PopAndDestroy(); // reader |
|
1157 } |
|
1158 #endif //CAMERAAPP_PLUGIN_BUILD |
|
1159 |
|
1160 // --------------------------------------------------------------------------- |
|
1161 // CCamStaticSettingsModel::Configuration |
|
1162 // |
|
1163 // --------------------------------------------------------------------------- |
|
1164 // |
|
1165 CCamConfiguration& |
|
1166 CCamStaticSettingsModel::Configuration() const |
|
1167 { |
|
1168 return iConfiguration; |
|
1169 } |
|
1170 |
|
1171 // |
|
1172 // CCamStaticSettingsModel::LoadPhotoStaticSettingsL |
|
1173 // |
|
1174 void CCamStaticSettingsModel::LoadPhotoStaticSettingsL( const TBool aResetFromPlugin ) |
|
1175 { |
|
1176 if ( aResetFromPlugin ) |
|
1177 { |
|
1178 LoadCommonStaticSettingsL( aResetFromPlugin ); |
|
1179 iStaticPhotoIntSettings.ResetAndDestroy(); |
|
1180 } |
|
1181 // Load Photo/Image Settings |
|
1182 ReadFromCenRepL( static_cast<TInt>( ECamSettingItemStaticPhotoRangeMin ), |
|
1183 static_cast<TInt>( ECamSettingItemPhotoCompression ), |
|
1184 iStaticPhotoIntSettings ); |
|
1185 |
|
1186 } |
|
1187 |
|
1188 // |
|
1189 // CCamStaticSettingsModel::LoadVideoStaticSettingsL |
|
1190 // |
|
1191 void CCamStaticSettingsModel::LoadVideoStaticSettingsL( const TBool aResetFromPlugin ) |
|
1192 { |
|
1193 if ( aResetFromPlugin ) |
|
1194 { |
|
1195 LoadCommonStaticSettingsL( aResetFromPlugin ); |
|
1196 iStaticVideoIntSettings.ResetAndDestroy(); |
|
1197 } |
|
1198 // Load Video Settings |
|
1199 ReadFromCenRepL( static_cast<TInt>( ECamSettingItemStaticVideoRangeMin ), |
|
1200 static_cast<TInt>( ECamSettingItemVideoOpZoomOff ), |
|
1201 iStaticVideoIntSettings ); |
|
1202 |
|
1203 } |
|
1204 |
|
1205 // |
|
1206 // CCamStaticSettingsModel::LoadCommonStaticSettingsL |
|
1207 // |
|
1208 void CCamStaticSettingsModel::LoadCommonStaticSettingsL( const TBool aResetFromPlugin ) |
|
1209 { |
|
1210 if ( aResetFromPlugin ) |
|
1211 { |
|
1212 iStaticCommonIntSettings.ResetAndDestroy(); |
|
1213 } |
|
1214 // Load Common Settings |
|
1215 ReadFromCenRepL( static_cast<TInt>( ECamSettingItemStaticCommonRangeMin ), |
|
1216 static_cast<TInt>( ECamSettingItemStaticCommonRangeMax ), |
|
1217 iStaticCommonIntSettings ); |
|
1218 } |
|
1219 |
|
1220 /* |
|
1221 * Handle to Camera Ui Config Manager |
|
1222 */ |
|
1223 CCameraUiConfigManager* CCamStaticSettingsModel::UiConfigManagerPtr() |
|
1224 { |
|
1225 return iConfigManager; |
|
1226 } |
|
1227 //End of File |
|