|
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: Utility functions for the Camera Application* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <bldvariant.hrh> // for feature definitions |
|
21 |
|
22 #include <aknappui.h> // CEikonEnv::Static()->FsSession() |
|
23 #include <AknSkinsInternalCRKeys.h> |
|
24 #include <aknnotewrappers.h> |
|
25 |
|
26 #include <AknCommonDialogsDynMem.h> |
|
27 #include <driveinfo.h> |
|
28 |
|
29 #include <sysutil.h> // SysUtil::DiskSpaceBelowCriticalLevelL() |
|
30 #include <pathinfo.h> |
|
31 #include <eikapp.h> // CEikApplication |
|
32 #include <collate.h> // TCollateMethod |
|
33 #include <e32property.h> |
|
34 #include <centralrepository.h> |
|
35 #include <MmsEngineInternalCRKeys.h> // MMS cenrep keys |
|
36 #include <hwrmpowerstatesdkpskeys.h> |
|
37 #include <coreapplicationuisdomainpskeys.h> // USB connection |
|
38 #include <locationtrailpskeys.h> |
|
39 #include <AvkonInternalCRKeys.h> // KAknQwertyInputModeActive |
|
40 |
|
41 #include <layoutmetadata.cdl.h> |
|
42 #include <aknlayoutscalable_apps.cdl.h> |
|
43 |
|
44 #if defined(RD_MDS_2_5) && !defined(__WINSCW__) && !defined(__WINS__) |
|
45 #include <harvesterclient.h> |
|
46 #endif // defined(RD_MDS_2_5) && !defined(__WINSCW__) && !defined(__WINS__) |
|
47 |
|
48 |
|
49 #include <glxcollectionmanager.h> |
|
50 |
|
51 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
52 #include <cameraapp.rsg> |
|
53 #include <vgacamsettings.rsg> |
|
54 #else |
|
55 #include <gscamerapluginrsc.rsg> |
|
56 #endif //CAMERAAPP_PLUGIN_BUILD |
|
57 |
|
58 #include "CamUtility.h" |
|
59 #include "CamPanic.h" |
|
60 #include "CameraappPrivateCRKeys.h" |
|
61 #include "camuidconstants.h" |
|
62 |
|
63 |
|
64 // CONSTANTS |
|
65 const TInt KCamNhdWidth = 640; |
|
66 const TInt KCamNhdHeight = 360; |
|
67 |
|
68 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
69 |
|
70 #include "CamAppUi.h" |
|
71 #include "CameraUiConfigManager.h" |
|
72 #include "CamResourceLookup.h" |
|
73 |
|
74 // =========================================================================== |
|
75 // CONSTANTS |
|
76 const TInt KMicSecInHalfSec = 500000; |
|
77 const TInt KMicSecInQuartSec = 250000; |
|
78 |
|
79 const TInt KCaptureLongPress = 500; // value in milliseconds |
|
80 |
|
81 // UI EV range |
|
82 const TInt KEVCompMinVal = -2; |
|
83 const TInt KEVCompMaxVal = 2; |
|
84 const TInt KEVCompStepsPerUnit = 2; |
|
85 |
|
86 // Limit for burst captured images |
|
87 const TInt KMaxBurstImages = 18; |
|
88 |
|
89 // Timeout value for courtesyUI |
|
90 const TInt KCourtesyUiTimeoutValue = 5; |
|
91 |
|
92 // Self-timer constants |
|
93 const TInt KMicroSecPerSec = 1000000; |
|
94 |
|
95 #endif //CAMERAAPP_PLUGIN_BUILD |
|
96 |
|
97 |
|
98 // ============================ MEMBER FUNCTIONS =============================== |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CamUtility::MemoryFree |
|
103 // Get free space in selected memory |
|
104 // |
|
105 // Returns: free space in selected memory (in bytes) minus the disk critical space |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 |
|
109 TInt64 CamUtility::MemoryFree( |
|
110 //AknCommonDialogsDynMem::TMemoryTypes aMemory, |
|
111 DriveInfo::TDefaultDrives aMemory, |
|
112 TInt aCriticalLevel ) |
|
113 { |
|
114 PRINT( _L("Camera => CamUtility::MemoryFree") ); |
|
115 TVolumeInfo vinfo; |
|
116 TInt error = KErrNone; |
|
117 |
|
118 // if measuring space on memory card |
|
119 if ( aMemory == DriveInfo::EDefaultRemovableMassStorage )//AknCommonDialogsDynMem::EMemoryTypeMMC ) |
|
120 { |
|
121 error = CEikonEnv::Static()->FsSession().Volume( |
|
122 vinfo, MemoryCardDrive() ); |
|
123 if ( error || MemoryCardStatus() != ECamMemoryCardInserted ) |
|
124 { |
|
125 PRINT( _L("Camera <= CamUtility::MemoryFree, failed to get volume info 1!!") ); |
|
126 return 0; |
|
127 } |
|
128 } |
|
129 else if ( aMemory == DriveInfo::EDefaultMassStorage )//AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage ) |
|
130 { |
|
131 error = CEikonEnv::Static()->FsSession().Volume( |
|
132 vinfo, MassMemoryDrive() ); |
|
133 } |
|
134 else // otherwise, measuring space on the phone memory |
|
135 { |
|
136 error = CEikonEnv::Static()->FsSession().Volume( |
|
137 vinfo, PhoneMemoryDrive() ); |
|
138 } |
|
139 |
|
140 if ( error ) // if getting the volume info failed |
|
141 { |
|
142 PRINT( _L("Camera <= CamUtility::MemoryFree, failed to get volume info 2!!") ); |
|
143 return 0; // indicate not enough space |
|
144 } |
|
145 PRINT( _L("Camera <= CamUtility::MemoryFree") ); |
|
146 return vinfo.iFree - aCriticalLevel; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CamUtility::MemoryCardStatus |
|
151 // Returns the current status of the MMC |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 TCamMemoryCardStatus CamUtility::MemoryCardStatus() |
|
155 { |
|
156 PRINT( _L("Camera => CamUtility::MemoryCardStatus") ); |
|
157 TDriveInfo driveInfo; |
|
158 |
|
159 CEikonEnv::Static()->FsSession().Drive( driveInfo, MemoryCardDrive() ); |
|
160 |
|
161 // Check if the MMC is currently locked. |
|
162 // If mmc is locked, then driveInfo.iType is zero, therefore switch clause |
|
163 // below does not notice new card |
|
164 // Check iMediaAtt instead, if media can be locked and is currently locked |
|
165 // and has password, then locked MMC is inserted |
|
166 |
|
167 TCamMemoryCardStatus mmcStatus( ECamMemoryCardNotInserted ); |
|
168 |
|
169 if ( ( driveInfo.iMediaAtt & ( KMediaAttLockable|KMediaAttLocked|KMediaAttHasPassword ) ) |
|
170 == ( KMediaAttLockable|KMediaAttLocked|KMediaAttHasPassword ) ) |
|
171 { |
|
172 mmcStatus = ECamMemoryCardLocked; |
|
173 } |
|
174 else |
|
175 { |
|
176 switch( driveInfo.iType ) |
|
177 { |
|
178 case EMediaNotPresent: |
|
179 { |
|
180 mmcStatus = ECamMemoryCardNotInserted; |
|
181 break; |
|
182 } |
|
183 default: |
|
184 { |
|
185 mmcStatus = ECamMemoryCardInserted; |
|
186 break; |
|
187 } |
|
188 } |
|
189 } |
|
190 // Check that volume is valid (ie. MMC is not corrupted) |
|
191 TVolumeInfo volumeInfo; |
|
192 TInt error = CEikonEnv::Static()->FsSession().Volume( volumeInfo, MemoryCardDrive() ); |
|
193 if ( error ) |
|
194 { |
|
195 mmcStatus = ECamMemoryCardNotInserted; |
|
196 } |
|
197 PRINT( _L("Camera <= CamUtility::MemoryCardStatus") ); |
|
198 return mmcStatus; |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CamUtility::MemoryCardDrive |
|
204 // Get drive number for memory card. |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CamUtility::MemoryCardDrive() |
|
208 { |
|
209 // Get the root path of the default memory card. |
|
210 TInt drive; |
|
211 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ); |
|
212 if ( err != KErrNone ) |
|
213 { |
|
214 return err; |
|
215 } |
|
216 TFileName path; |
|
217 err = PathInfo::GetRootPath( path, drive ); |
|
218 if ( err != KErrNone ) |
|
219 { |
|
220 return err; |
|
221 } |
|
222 TInt res = 0; |
|
223 err = RFs::CharToDrive( path[0], res ); |
|
224 __ASSERT_ALWAYS( !err, CamPanic( ECamPanicFileSystemError ) ); |
|
225 // return the memory card drive number |
|
226 return res; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CamUtility::PhoneMemoryDrive |
|
231 // Get drive number for phone memory. |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CamUtility::PhoneMemoryDrive() |
|
235 { |
|
236 // Get the root path of the default phone memory. |
|
237 TInt drive; |
|
238 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive ); |
|
239 if ( err != KErrNone ) |
|
240 { |
|
241 return err; |
|
242 } |
|
243 TFileName path; |
|
244 err = PathInfo::GetRootPath( path, drive ); |
|
245 if ( err != KErrNone ) |
|
246 { |
|
247 return err; |
|
248 } |
|
249 TInt res = 0; |
|
250 err = RFs::CharToDrive( path[0], res ); |
|
251 __ASSERT_ALWAYS( !err, CamPanic( ECamPanicFileSystemError ) ); |
|
252 // return the phone memory drive number |
|
253 return res; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CamUtility::MassMemoryDrive |
|
258 // Get drive number for mass storage memory. |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 TInt CamUtility::MassMemoryDrive() |
|
262 { |
|
263 // Get the root path of the default mass storage memory. |
|
264 TInt drive; |
|
265 TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ); |
|
266 if ( err != KErrNone ) |
|
267 { |
|
268 return err; |
|
269 } |
|
270 TFileName path; |
|
271 err = PathInfo::GetRootPath( path, drive ); |
|
272 if ( err != KErrNone ) |
|
273 { |
|
274 return err; |
|
275 } |
|
276 TInt res = 0; |
|
277 err = RFs::CharToDrive( path[0], res ); |
|
278 __ASSERT_ALWAYS( !err, CamPanic( ECamPanicFileSystemError ) ); |
|
279 // return the mass storage memory drive number |
|
280 return res; |
|
281 } |
|
282 |
|
283 |
|
284 TInt CamUtility::GetDriveTypeFromDriveNumber( TInt aDrive ) |
|
285 { |
|
286 TInt drive; |
|
287 TInt returnVal = DriveInfo::EDefaultPhoneMemory; |
|
288 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive ); |
|
289 if ( drive == aDrive ) |
|
290 { |
|
291 returnVal = DriveInfo::EDefaultPhoneMemory; |
|
292 } |
|
293 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive ); |
|
294 if ( drive == aDrive ) |
|
295 { |
|
296 returnVal = DriveInfo::EDefaultMassStorage; |
|
297 } |
|
298 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive ); |
|
299 if ( drive == aDrive ) |
|
300 { |
|
301 returnVal = DriveInfo::EDefaultRemovableMassStorage; |
|
302 } |
|
303 return returnVal; |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // CamUtility::MapToSettingsListMemory |
|
308 // Return settings list mapped value |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 |
|
312 TInt CamUtility::MapToSettingsListMemory( TInt aStorage ) |
|
313 { |
|
314 TInt mappedMemory; |
|
315 switch ( aStorage ) |
|
316 { |
|
317 case ECamMediaStoragePhone: |
|
318 { |
|
319 mappedMemory = DriveInfo::EDefaultPhoneMemory; |
|
320 } |
|
321 break; |
|
322 case ECamMediaStorageCard: |
|
323 { |
|
324 mappedMemory = DriveInfo::EDefaultRemovableMassStorage; |
|
325 } |
|
326 break; |
|
327 case ECamMediaStorageMassStorage: |
|
328 { |
|
329 mappedMemory = DriveInfo::EDefaultMassStorage; |
|
330 } |
|
331 break; |
|
332 default: |
|
333 { |
|
334 mappedMemory = KErrNotFound; |
|
335 } |
|
336 break; |
|
337 } |
|
338 return mappedMemory; |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CamUtility::MapFromSettingsListMemory |
|
343 // Return camera storage location mapped from settings list value |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 TInt CamUtility::MapFromSettingsListMemory( TInt aStorage ) |
|
347 { |
|
348 TInt mappedMemory; |
|
349 switch ( aStorage ) |
|
350 { |
|
351 case DriveInfo::EDefaultPhoneMemory: |
|
352 { |
|
353 mappedMemory = ECamMediaStoragePhone; |
|
354 } |
|
355 break; |
|
356 case DriveInfo::EDefaultRemovableMassStorage: |
|
357 { |
|
358 mappedMemory = ECamMediaStorageCard; |
|
359 } |
|
360 break; |
|
361 case DriveInfo::EDefaultMassStorage: |
|
362 { |
|
363 mappedMemory = ECamMediaStorageMassStorage; |
|
364 } |
|
365 break; |
|
366 default: |
|
367 { |
|
368 mappedMemory = KErrNotFound; |
|
369 } |
|
370 break; |
|
371 } |
|
372 return mappedMemory; |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // CamUtility::GetUniqueNameL |
|
377 // Suggest a new unique filename using the name stub provided in aFilename |
|
378 // and adding a numbered postfix to ensure uniqueness |
|
379 // The full filename is returned in aFilePath. The name of the file only, is |
|
380 // returned in aFilename |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 void CamUtility::GetUniqueNameL( TDes& aFilePath, |
|
384 TDes& aFilename, |
|
385 TInt aSuggestedNumeral, |
|
386 const TDesC& aExt ) |
|
387 { |
|
388 PRINT( _L("Camera => CamUtility::GetUniqueNameL") ); |
|
389 // Leave if there is a problem with the passed directory path. |
|
390 TEntry entry; |
|
391 RFs rfs; |
|
392 User::LeaveIfError( rfs.Connect( ) ); |
|
393 CleanupClosePushL( rfs ); |
|
394 User::LeaveIfError( rfs.Entry( aFilePath, entry ) ); |
|
395 // check it actually is a directory |
|
396 if( !entry.IsDir() ) |
|
397 { |
|
398 PRINT( _L("Camera => CamUtility::GetUniqueNameL not dir") ); |
|
399 User::Leave( KErrCorrupt ); |
|
400 } |
|
401 |
|
402 TInt namelen = aFilename.Length(); |
|
403 |
|
404 TFileName nameBase( aFilename.Left( namelen ) ); |
|
405 |
|
406 TBool done = EFalse; |
|
407 TInt counter = aSuggestedNumeral; |
|
408 |
|
409 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
410 |
|
411 while ( !done ) |
|
412 { |
|
413 // Generate new name |
|
414 FormatFileName( counter, nameBase, aFilename ); |
|
415 |
|
416 TFileName newPath( aFilePath ); |
|
417 newPath.Append( aFilename ); |
|
418 newPath.Append( aExt ); |
|
419 |
|
420 // define new instance of TEntry to prevent LINT error |
|
421 TEntry newEntry; |
|
422 TInt ferr = fs.Entry( newPath, newEntry ); |
|
423 // if there is no file in the current location with this name |
|
424 if ( ferr == KErrNotFound ) |
|
425 { |
|
426 done = ETrue; |
|
427 aFilePath.Copy( newPath ); |
|
428 } |
|
429 else if( ferr == KErrNone )// the filename has already been used in this location |
|
430 { |
|
431 // try the next number |
|
432 ++counter; |
|
433 } |
|
434 else |
|
435 { |
|
436 User::Leave( ferr ); |
|
437 } |
|
438 } |
|
439 CleanupStack::PopAndDestroy( &rfs ); |
|
440 PRINT( _L("Camera => CamUtility::GetUniqueNameL") ); |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CamUtility::FormatFileName |
|
445 // Generate a file name based on base name and counter. |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 void CamUtility::FormatFileName( TUint aCounter, |
|
449 const TDesC& aBaseName, |
|
450 TDes& aFilename ) |
|
451 { |
|
452 const TUint KMax3Digits = 999; |
|
453 _LIT( KCamNameFormatFirst, "%S" ); // "Photo" |
|
454 _LIT( KCamNameFormat3Digits, "%S%03d" ); // "Photo001" |
|
455 _LIT( KCamNameFormat4Digits, "%S%d" ); // "Photo1234" |
|
456 |
|
457 // if the number is 0 |
|
458 if ( aCounter == 0 ) |
|
459 { |
|
460 aFilename.Format( KCamNameFormatFirst, &aBaseName ); |
|
461 } |
|
462 else if ( aCounter <= KMax3Digits ) // the number is 1 - 999 |
|
463 { |
|
464 aFilename.Format( KCamNameFormat3Digits, &aBaseName, aCounter ); |
|
465 } |
|
466 else // the number is > 999 |
|
467 { |
|
468 aFilename.Format( KCamNameFormat4Digits, &aBaseName, aCounter ); |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // CamUtility::CheckFileNameValidityL |
|
474 // Checks if given filename contains illegal characters or |
|
475 // is otherwise illegal. |
|
476 // --------------------------------------------------------------------------- |
|
477 // |
|
478 TBool CamUtility::CheckFileNameValidityL( const TDesC& aFilename ) |
|
479 { |
|
480 // For filename validity checking |
|
481 _LIT( KSingleDot, "." ); |
|
482 _LIT( KDoubleDot, ".." ); |
|
483 _LIT( KBackslash, "\\" ); |
|
484 |
|
485 // "." and ".." are not valid filenames |
|
486 if ( aFilename.Compare( KSingleDot ) == 0 || |
|
487 aFilename.Compare( KDoubleDot ) == 0 ) |
|
488 { |
|
489 CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper(); |
|
490 note->ExecuteLD( R_CAM_UNSUITABLE_FILENAME ); |
|
491 return EFalse; |
|
492 } |
|
493 |
|
494 // No backslashes in filenames. |
|
495 // File server checks for other special characters. |
|
496 if ( aFilename.Find( KBackslash ) != KErrNotFound || |
|
497 !CCoeEnv::Static()->FsSession().IsValidName( aFilename ) ) |
|
498 { |
|
499 CAknNoteWrapper* note = new ( ELeave ) CAknNoteWrapper(); |
|
500 note->ExecuteLD( R_CAM_ILLEGAL_CHARACTERS ); |
|
501 return EFalse; |
|
502 } |
|
503 |
|
504 // File name is okay. |
|
505 return ETrue; |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // CamUtility::FormatDateFileNameL |
|
510 // Generate a file name based on date and counter. |
|
511 // --------------------------------------------------------------------------- |
|
512 // |
|
513 void CamUtility::FormatDateFileNameL( TDes& aFilename ) |
|
514 { |
|
515 const TInt KCamMaxDateLen = 8; |
|
516 |
|
517 _LIT( KCamNameFormatFirst, "%S" ); // "Image" |
|
518 |
|
519 TBuf<KCamMaxDateLen> date; |
|
520 GetCurrentDateForNameBaseL( date ); |
|
521 |
|
522 aFilename.Format( KCamNameFormatFirst, &date ); |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // CamUtility::GetCurrentDateForNameBaseL |
|
527 // Format current date into given descriptor in a format |
|
528 // suitable for file names. |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 void CamUtility::GetCurrentDateForNameBaseL( TDes& aBuffer ) |
|
532 { |
|
533 const TInt KCamDateFormatLength = 8; |
|
534 _LIT( KCamEuropeanDateFormat, "%F%D%M%Y" ); |
|
535 _LIT( KCamAmericanDateFormat, "%F%M%D%Y" ); |
|
536 _LIT( KCamJapaneseDateFormat, "%F%Y%M%D" ); |
|
537 |
|
538 TTime now; |
|
539 now.HomeTime(); |
|
540 TLocale locale; |
|
541 TBuf<KCamDateFormatLength> dateFormat; |
|
542 |
|
543 switch ( locale.DateFormat() ) |
|
544 { |
|
545 case EDateAmerican: |
|
546 { |
|
547 dateFormat = KCamAmericanDateFormat; |
|
548 break; |
|
549 } |
|
550 |
|
551 case EDateJapanese: |
|
552 { |
|
553 dateFormat = KCamJapaneseDateFormat; |
|
554 break; |
|
555 } |
|
556 |
|
557 case EDateEuropean: |
|
558 default: |
|
559 { |
|
560 dateFormat = KCamEuropeanDateFormat; |
|
561 break; |
|
562 } |
|
563 } |
|
564 |
|
565 now.FormatL( aBuffer, dateFormat ); |
|
566 } |
|
567 |
|
568 // --------------------------------------------------------------------------- |
|
569 // CamUtility::ResourceFileName |
|
570 // Return the name and path of the application MBM file. |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 void CamUtility::ResourceFileName( TDes& aResName ) |
|
574 { |
|
575 _LIT(KResName, "z:\\resource\\apps\\cameraapp.mbm"); |
|
576 |
|
577 aResName = KResName(); |
|
578 } |
|
579 |
|
580 |
|
581 // --------------------------------------------------------------------------- |
|
582 // CamUtility::GetMaxMmsSizeL |
|
583 // Get maximum MMS message size |
|
584 // --------------------------------------------------------------------------- |
|
585 // |
|
586 TInt CamUtility::MaxMmsSizeInBytesL() |
|
587 { |
|
588 const TUint32 KCCorMaxMms = 0x00000006; |
|
589 |
|
590 TInt maxSize = 0; |
|
591 |
|
592 CRepository* mmsRepository = CRepository::NewLC( KCRUidMmsEngine ); |
|
593 User::LeaveIfError( mmsRepository->Get( |
|
594 KMmsEngineMaximumSendSize, maxSize ) ); |
|
595 |
|
596 if ( !maxSize ) |
|
597 { |
|
598 CRepository *repository = CRepository::NewLC( KCRUidCamcorderFeatures ); |
|
599 |
|
600 // Maximum MMS size not defined in Camcorder local variation |
|
601 // ini file, try the MMS ini file |
|
602 User::LeaveIfError( repository->Get( |
|
603 KCCorMaxMms, |
|
604 maxSize ) ); |
|
605 |
|
606 CleanupStack::PopAndDestroy( repository ); |
|
607 } |
|
608 |
|
609 const TInt KKiloByte = 1024; |
|
610 // How many bytes to allocate for other things than |
|
611 // video in a MMS message |
|
612 const TInt KMmsSizeReserve = 5 * KKiloByte; |
|
613 |
|
614 // Convert to kilobytes, leave some space for other things |
|
615 maxSize = Max( maxSize - KMmsSizeReserve, 0 ); |
|
616 |
|
617 |
|
618 |
|
619 //delete mmsRepository; |
|
620 CleanupStack::PopAndDestroy( mmsRepository ); |
|
621 return maxSize; |
|
622 } |
|
623 |
|
624 // --------------------------------------------------------------------------- |
|
625 // CcorUtility::CompareIgnoreCase |
|
626 // Compare two descriptors |
|
627 // --------------------------------------------------------------------------- |
|
628 // |
|
629 TBool CamUtility::CompareIgnoreCase( const TDesC& aFirst, |
|
630 const TDesC& aSecond ) |
|
631 { |
|
632 // Get the standard method |
|
633 TCollationMethod m = *Mem::CollationMethodByIndex( 0 ); |
|
634 m.iFlags |= TCollationMethod::EFoldCase; |
|
635 m.iFlags |= TCollationMethod::EIgnoreNone; |
|
636 |
|
637 // Magic: Collation level 3 is used |
|
638 return aFirst.CompareC( aSecond, 3, &m ) == 0; |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // CamUtility::DeleteVideoL |
|
643 // Delete a video clip. |
|
644 // --------------------------------------------------------------------------- |
|
645 // |
|
646 void CamUtility::DeleteVideoL( const TDesC& aFilename ) |
|
647 { |
|
648 TInt err = CEikonEnv::Static()->FsSession().Delete( aFilename ); |
|
649 if ( err && err != KErrNotFound ) |
|
650 { |
|
651 User::Leave( err ); |
|
652 } |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // CamUtility::DeleteStillImageL |
|
657 // Delete a still image. |
|
658 // --------------------------------------------------------------------------- |
|
659 // |
|
660 void CamUtility::DeleteStillImageL( const TDesC& aFilename ) |
|
661 { |
|
662 TInt err = CEikonEnv::Static()->FsSession().Delete( aFilename ); |
|
663 if ( err && err != KErrNotFound ) |
|
664 { |
|
665 User::Leave( err ); |
|
666 } |
|
667 |
|
668 TFileName thumbnailPath; |
|
669 GetThumbnailPath( aFilename, thumbnailPath ); |
|
670 |
|
671 // ignore error |
|
672 CEikonEnv::Static()->FsSession().Delete( thumbnailPath ); |
|
673 } |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // CamUtility::GetThumbnailPath |
|
677 // Get full path to a thumbnail file corresponding to given image file. |
|
678 // --------------------------------------------------------------------------- |
|
679 void CamUtility::GetThumbnailPath( const TDesC& aImagePath, |
|
680 TDes& aThumbnailPath ) |
|
681 { |
|
682 TParsePtrC parse( aImagePath ); |
|
683 aThumbnailPath = parse.DriveAndPath(); |
|
684 aThumbnailPath.Append( PathInfo::ImagesThumbnailPath() ); |
|
685 aThumbnailPath.Append( parse.NameAndExt() ); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 // CamUtility::RenameStillImageL |
|
690 // Rename a still image file. |
|
691 // --------------------------------------------------------------------------- |
|
692 // |
|
693 void CamUtility::RenameStillImageL( const TDesC& aOldPath, |
|
694 const TDesC& aNewName, |
|
695 TDes& aNewPath ) |
|
696 { |
|
697 CFileMan* fileMan = CFileMan::NewL( CEikonEnv::Static()->FsSession() ); |
|
698 CleanupStack::PushL( fileMan ); |
|
699 |
|
700 TParsePtrC parse( aOldPath ); |
|
701 TFileName fullNewPath; |
|
702 fullNewPath = parse.DriveAndPath(); |
|
703 fullNewPath.Append( aNewName ); |
|
704 fullNewPath.Append( parse.Ext() ); |
|
705 |
|
706 // Rename image file |
|
707 User::LeaveIfError( fileMan->Rename( aOldPath, fullNewPath, 0 ) ); |
|
708 // NOTE: flags = 0 --> attempting overwrite will leave |
|
709 |
|
710 aNewPath = fullNewPath; |
|
711 |
|
712 // Rename thumbnail |
|
713 TFileName oldThumbPath; |
|
714 TFileName newThumbPath; |
|
715 GetThumbnailPath( aOldPath, oldThumbPath ); |
|
716 GetThumbnailPath( aNewPath, newThumbPath ); |
|
717 |
|
718 // ignore error |
|
719 fileMan->Rename( oldThumbPath, newThumbPath, CFileMan::EOverWrite ); |
|
720 |
|
721 CleanupStack::PopAndDestroy(); // fileMan |
|
722 } |
|
723 |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CamUtility::IdMatchesName |
|
727 // Checks whether the window ID corresponds to the ground name supplied. |
|
728 // ----------------------------------------------------------------------------- |
|
729 // |
|
730 TBool CamUtility::IdMatchesName( TInt aWindowId, const TDesC& aWindowGroupName ) |
|
731 { |
|
732 PRINT2(_L("Camera => CamUtility::IdMatchesName ( %d, %S )"), aWindowId, &aWindowGroupName ); |
|
733 |
|
734 const TInt KMaxWGName = 256; |
|
735 |
|
736 TBuf <KMaxWGName> name; |
|
737 |
|
738 // Look up the window group name from the supplied ID. |
|
739 CEikonEnv::Static()->WsSession().GetWindowGroupNameFromIdentifier( aWindowId, name ); |
|
740 |
|
741 // We have to do some manipulation, as the window group name string |
|
742 // contains NULL seperators which will stop a normal descriptor Find |
|
743 // operation from finding the string needed. |
|
744 for ( TInt i=0; i<name.Length(); i++) // Replace any "null" chars with space |
|
745 { |
|
746 if ( name[i] == NULL ) |
|
747 { |
|
748 name[i] = ' '; |
|
749 } |
|
750 } |
|
751 |
|
752 PRINT1(_L("Camera CamUtility::IdMatchesName tidied name '%S'"), &name); |
|
753 |
|
754 TInt ret = name.Find( aWindowGroupName ); |
|
755 |
|
756 PRINT2(_L("Camera CamUtility::IdMatchesName ret=%d, return(%d)"), ret, ret != KErrNotFound); |
|
757 return ( ret != KErrNotFound ); |
|
758 } |
|
759 |
|
760 |
|
761 // ----------------------------------------------------------------------------- |
|
762 // CamUtility::IsBatteryPowerOK |
|
763 // Returns ETrue if the battery power is good |
|
764 // ----------------------------------------------------------------------------- |
|
765 // |
|
766 TBool CamUtility::IsBatteryPowerOK() |
|
767 { |
|
768 PRINT(_L("Camera => CamUtility::IsBatteryPowerOK")); |
|
769 TBool isBatteryOK = EFalse; // Default to battery low |
|
770 |
|
771 TInt strength = EBatteryStatusUnknown; |
|
772 TInt result = RProperty::Get( KPSUidHWRMPowerState, KHWRMBatteryStatus, strength ); |
|
773 PRINT2(_L("Camera CamUtility::IsBatteryPowerOK result=%d, strength=%d"), result, strength); |
|
774 if ( result == KErrNone && strength == EBatteryStatusOk ) |
|
775 { |
|
776 isBatteryOK = ETrue; |
|
777 } |
|
778 |
|
779 PRINT1(_L("Camera <= CamUtility::IsBatteryPowerOK return(%d)"), isBatteryOK); |
|
780 return isBatteryOK; |
|
781 } |
|
782 |
|
783 |
|
784 // ----------------------------------------------------------------------------- |
|
785 // CamUtility::IsBatteryPowerEmpty |
|
786 // Returns ETrue if the battery power is empty |
|
787 // ----------------------------------------------------------------------------- |
|
788 // |
|
789 TBool CamUtility::IsBatteryPowerEmpty() |
|
790 { |
|
791 PRINT(_L("Camera => CamUtility::IsBatteryPowerEmpty")); |
|
792 TBool isBatteryEmpty = EFalse; |
|
793 |
|
794 TInt strength = EBatteryStatusUnknown; |
|
795 TInt result = RProperty::Get( KPSUidHWRMPowerState, KHWRMBatteryStatus, strength ); |
|
796 PRINT2(_L("Camera CamUtility::IsBatteryPowerEmpty result=%d, strength=%d"), result, strength); |
|
797 if ( result == KErrNone && strength == EBatteryStatusEmpty ) |
|
798 { |
|
799 isBatteryEmpty = ETrue; |
|
800 } |
|
801 |
|
802 PRINT1(_L("Camera <= CamUtility::IsBatteryPowerEmpty return(%d)"), isBatteryEmpty); |
|
803 return isBatteryEmpty; |
|
804 } |
|
805 |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CamUtility::IsBatteryCharging |
|
809 // Returns ETrue if the battery is being charged |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 TBool CamUtility::IsBatteryCharging() |
|
813 { |
|
814 PRINT(_L("Camera => CamUtility::IsBatteryCharging")); |
|
815 TBool isCharging = EFalse; // Default to not charging |
|
816 |
|
817 TInt charge = EChargingStatusError; |
|
818 TInt result = RProperty::Get( KPSUidHWRMPowerState, KHWRMChargingStatus, charge ); |
|
819 PRINT2(_L("Camera CamUtility::IsBatteryCharging result=%d, charge=%d"), result, charge); |
|
820 if ( (result == KErrNone) && (charge == EChargingStatusCharging || |
|
821 charge == EChargingStatusAlmostComplete || |
|
822 charge == EChargingStatusChargingContinued || |
|
823 charge == EChargingStatusChargingComplete) ) |
|
824 { |
|
825 isCharging = ETrue; |
|
826 } |
|
827 PRINT1(_L("Camera <= CamUtility::IsBatteryCharging return(%d)"), isCharging); |
|
828 |
|
829 return isCharging; |
|
830 } |
|
831 |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CamUtility::IsLocationAware() |
|
835 // Returns ETrue if LocationTrail is started and valid GPS data is available |
|
836 // ----------------------------------------------------------------------------- |
|
837 // |
|
838 TBool CamUtility::IsLocationAware() |
|
839 { |
|
840 #ifndef __WINSCW__ |
|
841 TBool ret = EFalse; |
|
842 TInt keyVal; |
|
843 TInt err = RProperty::Get( KPSUidLocationTrail, KLocationTrailState, keyVal ); |
|
844 if( KErrNone == err ) |
|
845 { |
|
846 if( KCamLocationTrailGPSDataAvail == keyVal ) |
|
847 { |
|
848 ret = ETrue; |
|
849 } |
|
850 } |
|
851 return ret; |
|
852 #else |
|
853 return ETrue; |
|
854 #endif // !__WINSCW__ |
|
855 } |
|
856 |
|
857 // --------------------------------------------------------- |
|
858 // CamUtility::SetAlphaL |
|
859 // --------------------------------------------------------- |
|
860 // |
|
861 void CamUtility::SetAlphaL( CFbsBitmap*& aBmp, CFbsBitmap*& aMask, |
|
862 TRgb aColor ) |
|
863 { |
|
864 // Draw EColor16MA bitmap: |
|
865 CFbsBitmap* bmpWithAlpha = new (ELeave) CFbsBitmap(); |
|
866 User::LeaveIfError( |
|
867 bmpWithAlpha->Create( aBmp->SizeInPixels(), EColor16MA) ); |
|
868 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( bmpWithAlpha ); |
|
869 CleanupStack::PushL( device ); |
|
870 CFbsBitGc* gc; |
|
871 User::LeaveIfError( device->CreateContext(gc) ); |
|
872 CleanupStack::PushL(gc); |
|
873 |
|
874 gc->BitBlt( TPoint(0,0), aBmp ); |
|
875 delete aBmp; |
|
876 aBmp = NULL; |
|
877 aBmp = bmpWithAlpha; |
|
878 |
|
879 CleanupStack::PopAndDestroy(gc); |
|
880 CleanupStack::PopAndDestroy(device); |
|
881 |
|
882 // Ensure mask colour depth |
|
883 TSize size = aMask->SizeInPixels(); |
|
884 TBool inv( EFalse ); |
|
885 if ( aMask->DisplayMode() != EGray256 ) |
|
886 { |
|
887 CFbsBitmap* bmp256 = new (ELeave) CFbsBitmap(); |
|
888 User::LeaveIfError( |
|
889 bmp256->Create( size, EGray256) ); |
|
890 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( bmp256 ); |
|
891 CleanupStack::PushL( device ); |
|
892 CFbsBitGc* gc; |
|
893 User::LeaveIfError( device->CreateContext(gc) ); |
|
894 CleanupStack::PushL(gc); |
|
895 gc->BitBlt( TPoint(0,0), aMask ); |
|
896 delete aMask; |
|
897 aMask = NULL; |
|
898 aMask = bmp256; |
|
899 CleanupStack::PopAndDestroy(gc); |
|
900 CleanupStack::PopAndDestroy(device); |
|
901 inv = ETrue; |
|
902 } |
|
903 |
|
904 // Add Alpha values: |
|
905 TUint32 dPitch = CFbsBitmap::ScanLineLength( size.iWidth, EColor16MA ) / 4; |
|
906 TUint32 maskPitch = CFbsBitmap::ScanLineLength( size.iWidth, EGray256 ); |
|
907 aMask->LockHeap(); |
|
908 aBmp->LockHeap(); |
|
909 |
|
910 // Component is not expected to deal with the extended bitmap. |
|
911 TUint32* destAddr = reinterpret_cast<TUint32*>( aBmp->DataAddress() ); |
|
912 |
|
913 for ( TUint32 y = 0; y < size.iHeight; y++ ) |
|
914 { |
|
915 HBufC8* maskBuf = HBufC8::NewLC( maskPitch ); |
|
916 TPtr8 maskPtr = maskBuf->Des(); |
|
917 aMask->GetScanLine( maskPtr, TPoint(0, y), size.iWidth, EGray256 ); |
|
918 for ( TUint32 x = 0; x < size.iWidth; x++ ) |
|
919 { |
|
920 TUint8 value = maskPtr[x]; |
|
921 if ( inv ) |
|
922 { |
|
923 value = ~value; |
|
924 } |
|
925 // Round mask value to fully opaque or transparent |
|
926 if ( value > 0x7f ) |
|
927 { |
|
928 // Opaque pixel. |
|
929 destAddr[ y * dPitch + x ] &= aColor.Internal(); |
|
930 destAddr[ y * dPitch + x ] |= 0xFF000000; |
|
931 } |
|
932 else |
|
933 { |
|
934 // Transparent pixel |
|
935 destAddr[ y * dPitch + x ] = 0x00000000; |
|
936 } |
|
937 } |
|
938 CleanupStack::PopAndDestroy(maskBuf); |
|
939 } |
|
940 |
|
941 aBmp->UnlockHeap(); |
|
942 aMask->UnlockHeap(); |
|
943 |
|
944 // Mask is not used for drawing |
|
945 delete aMask; |
|
946 aMask = NULL; |
|
947 } |
|
948 |
|
949 // --------------------------------------------------------- |
|
950 // CamUtility::IsUsbActive |
|
951 // --------------------------------------------------------- |
|
952 // |
|
953 TBool CamUtility::IsUsbActive() |
|
954 { |
|
955 TInt usbState; |
|
956 TInt err = RProperty::Get( KPSUidCoreApplicationUIs, |
|
957 KCoreAppUIsUSBFileTransfer, |
|
958 usbState ); |
|
959 return !err && usbState == ECoreAppUIsUSBFileTransferActive; |
|
960 } |
|
961 |
|
962 // --------------------------------------------------------- |
|
963 // CamUtility::IsNhdDevice for Layouts only |
|
964 // --------------------------------------------------------- |
|
965 // |
|
966 TBool CamUtility::IsNhdDevice() |
|
967 { |
|
968 TRect screenRect; |
|
969 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
970 TRect nhdRectLandscape( TSize( KCamNhdWidth, KCamNhdHeight ) ); |
|
971 TRect nhdRectPortrait( TSize( KCamNhdHeight, KCamNhdWidth ) ); |
|
972 |
|
973 return screenRect == nhdRectLandscape || screenRect == nhdRectPortrait; |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // CamUtility::GetPsiInt |
|
978 // Allows retrieval of product specific information (TInt) |
|
979 // --------------------------------------------------------------------------- |
|
980 // |
|
981 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
982 |
|
983 TInt CamUtility::GetPsiInt( TCamPsiKey aKey, TInt& aValue ) |
|
984 { |
|
985 aValue = KErrNotSupported; |
|
986 |
|
987 switch ( aKey ) |
|
988 { |
|
989 case ECamPsiOrientation: |
|
990 case ECamPsiPrimaryCameraOrientation: |
|
991 case ECamPsiSecondaryCameraOrientation: |
|
992 case ECamPsiEditingOrientation: |
|
993 return CamUtility::GetCommonPsiInt( aKey, aValue ); |
|
994 case ECamPsiOverLaySidePane: { aValue = ETrue; break; } |
|
995 case ECamPsiSidePanePosition: { aValue = ECamHandRight; break; } |
|
996 case ECamPsiSoftKeyPosition: { aValue = ECamHandRight; break; } |
|
997 |
|
998 case ECamPsiLeftNaviKey: { aValue = ECamNaviKeyCaptureSetup; break; } |
|
999 case ECamPsiLeftNaviKeyCam2: { aValue = ECamNaviKeyNone; break; } |
|
1000 case ECamPsiRightNaviKey: { aValue = ECamNaviKeyNone; break; } |
|
1001 case ECamPsiVideoZoomSupport: { aValue = ECamZoomWhenRecord; break; } |
|
1002 |
|
1003 |
|
1004 // Interval: return the value in units of 1000 microseconds |
|
1005 case ECamPsiLongCaptureKeyPressInterval: { aValue = KCaptureLongPress; break; } |
|
1006 case ECamPsiMaxBurstCapture: { aValue = KMaxBurstImages; break; } |
|
1007 case ECamPsiCourtesyUiTimeoutValue: { aValue = KCourtesyUiTimeoutValue; break; } |
|
1008 case ECamPsiAPEVCompLegend: { aValue = R_CAM_CAPTURE_SETUP_MENU_PHOTO_EXPOSURE_ARRAY2; break; } |
|
1009 default: |
|
1010 { |
|
1011 return KErrNotSupported; |
|
1012 } |
|
1013 } |
|
1014 return KErrNone; |
|
1015 } |
|
1016 |
|
1017 // --------------------------------------------------------------------------- |
|
1018 // CamUtility::GetPsiIntArrayL |
|
1019 // Allows retrieval of product specific information (TInt array) |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // |
|
1022 TInt CamUtility::GetPsiIntArrayL( TCamPsiKey aKey, RArray<TInt>& aArray ) |
|
1023 { |
|
1024 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
1025 CCameraUiConfigManager* configManager = appUi->AppController().UiConfigManagerPtr(); |
|
1026 |
|
1027 switch ( aKey ) |
|
1028 { |
|
1029 // Resource ids for User Scene setup items |
|
1030 case ECamPsiUserSceneResourceIds: |
|
1031 { |
|
1032 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_SCENEBASE_DATA ) ); |
|
1033 if ( configManager->IsFlashModeSupported() ) |
|
1034 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_FLASH_DATA ) ); |
|
1035 if ( configManager->IsWhiteBalanceFeatureSupported() ) |
|
1036 User::LeaveIfError( aArray.Append( |
|
1037 R_CAM_PHOTO_USER_SCENE_SETUP_LIST_WHITEBALANCE_DATA ) ); |
|
1038 if ( configManager->IsEVSupported() ) |
|
1039 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_EV_DATA2 ) ); |
|
1040 |
|
1041 if ( configManager->IsColorToneFeatureSupported() ) |
|
1042 User::LeaveIfError( aArray.Append( |
|
1043 R_CAM_PHOTO_USER_SCENE_SETUP_LIST_COLOUREFFECT_DATA ) ); |
|
1044 if ( configManager->IsISOSupported() ) |
|
1045 { |
|
1046 if ( configManager->IsExtendedLightSensitivitySupported() ) |
|
1047 { |
|
1048 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_EXTENDED_LIGHTSENSITIVITY_DATA ) ); |
|
1049 } |
|
1050 else { |
|
1051 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_LIGHTSENSITIVITY_DATA ) ); |
|
1052 } |
|
1053 } |
|
1054 |
|
1055 if ( configManager->IsSharpnessFeatureSupported() ) |
|
1056 User::LeaveIfError( aArray.Append( |
|
1057 R_CAM_PHOTO_USER_SCENE_SETUP_LIST_IMAGESHARPNESS_DATA ) ); |
|
1058 |
|
1059 if ( configManager->IsContrastSupported() ) |
|
1060 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_CONTRAST_DATA ) ); |
|
1061 |
|
1062 User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_RESET_DATA ) ); |
|
1063 break; |
|
1064 } |
|
1065 // ----------------------------------------------------- |
|
1066 default: |
|
1067 { |
|
1068 return KErrNotSupported; |
|
1069 } |
|
1070 } |
|
1071 return KErrNone; |
|
1072 } |
|
1073 |
|
1074 // --------------------------------------------------------------------------- |
|
1075 // CamUtility::GetPsiAnyL |
|
1076 // Allows retrieval of product specific information (TAny) |
|
1077 // --------------------------------------------------------------------------- |
|
1078 // |
|
1079 TInt CamUtility::GetPsiAnyL( TCamPsiKey aKey, TAny* aValue ) |
|
1080 { |
|
1081 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
1082 CCameraUiConfigManager* uiConfigManager = appUi->AppController().UiConfigManagerPtr(); |
|
1083 |
|
1084 RArray<TInt> zoomValues; |
|
1085 CleanupClosePushL( zoomValues ); |
|
1086 zoomValues.Reset(); |
|
1087 |
|
1088 typedef TPckgBuf<TCamMaxZoomSteps> TCamZoomStepPckg; |
|
1089 typedef TPckgBuf<TSelfTimerSetting> TCamTimerSetPckg; |
|
1090 typedef TPckgBuf<TCamZoomLAF> TCamZoomLAFPckg; |
|
1091 typedef TPckgBuf<TCamEvCompRange> TCamEVCompPckg; |
|
1092 |
|
1093 switch ( aKey ) |
|
1094 { |
|
1095 // ----------------------------------------------------- |
|
1096 // Self timer periods |
|
1097 case ECamPsiSelfTimerPeriod1: |
|
1098 { |
|
1099 // Default constructor assigns KErrNotSupported to all fields. |
|
1100 // See CamPSI.h. |
|
1101 TSelfTimerSetting timerPeriod1; |
|
1102 |
|
1103 // First period is at 2-seconds remaining, "always on" |
|
1104 timerPeriod1.iThreshold [0] = 2*KMicroSecPerSec; |
|
1105 timerPeriod1.iFlashPeriod[0] = KMaxTInt; |
|
1106 timerPeriod1.iBeepPeriod [0] = KMaxTInt; |
|
1107 |
|
1108 // There are no other periods |
|
1109 |
|
1110 // Autofocus triggered on "2-seconds remaining" |
|
1111 timerPeriod1.iAutoFocus = 2*KMicroSecPerSec; |
|
1112 |
|
1113 TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue ); |
|
1114 *ptr = timerPeriod1; |
|
1115 break; |
|
1116 } |
|
1117 case ECamPsiSelfTimerPeriod2: |
|
1118 { |
|
1119 TSelfTimerSetting timerPeriod2; |
|
1120 |
|
1121 // First period is at 10-seconds until capture, flashing once every second. |
|
1122 timerPeriod2.iThreshold [0] = 10*KMicroSecPerSec; |
|
1123 timerPeriod2.iFlashPeriod[0] = KMicSecInHalfSec; // 500ms on/500ms off |
|
1124 timerPeriod2.iBeepPeriod [0] = KMicroSecPerSec; // Beep every second |
|
1125 |
|
1126 // Second period starts at 3-seconds until capture, flashing twice every second |
|
1127 timerPeriod2.iThreshold [1] = 5*KMicroSecPerSec; |
|
1128 timerPeriod2.iFlashPeriod[1] = KMicSecInQuartSec; // 250ms on/250ms off |
|
1129 timerPeriod2.iBeepPeriod [1] = KMicSecInHalfSec; // Beep twice every second |
|
1130 |
|
1131 // Third period is not supported |
|
1132 timerPeriod2.iThreshold [2] = 3*KMicroSecPerSec; |
|
1133 timerPeriod2.iFlashPeriod[2] = KMaxTInt; |
|
1134 timerPeriod2.iBeepPeriod [2] = KMaxTInt; |
|
1135 |
|
1136 // Autofocus triggered on "3-seconds remaining" |
|
1137 timerPeriod2.iAutoFocus = 3*KMicroSecPerSec; |
|
1138 |
|
1139 TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue ); |
|
1140 *ptr = timerPeriod2; |
|
1141 break; |
|
1142 } |
|
1143 case ECamPsiSelfTimerPeriod3: |
|
1144 { |
|
1145 TSelfTimerSetting timerPeriod3; |
|
1146 |
|
1147 // First period is at 20-seconds until capture, flashing once every second. |
|
1148 timerPeriod3.iThreshold [0] = 20*KMicroSecPerSec; |
|
1149 timerPeriod3.iFlashPeriod[0] = KMicSecInHalfSec; // 500ms on/500ms off |
|
1150 timerPeriod3.iBeepPeriod [0] = KMicroSecPerSec; // Beep every second |
|
1151 |
|
1152 // Second period starts at 3-seconds until capture, flashing twice every second |
|
1153 timerPeriod3.iThreshold [1] = 5*KMicroSecPerSec; |
|
1154 timerPeriod3.iFlashPeriod[1] = KMicSecInQuartSec; // 250ms on/250ms off |
|
1155 timerPeriod3.iBeepPeriod [1] = KMicSecInHalfSec; // Beep twice every second |
|
1156 |
|
1157 // Third period is not supported |
|
1158 timerPeriod3.iThreshold [2] = 3*KMicroSecPerSec; |
|
1159 timerPeriod3.iFlashPeriod[2] = KMaxTInt; |
|
1160 timerPeriod3.iBeepPeriod [2] = KMaxTInt; |
|
1161 |
|
1162 // Autofocus triggered on "3-seconds remaining" |
|
1163 timerPeriod3.iAutoFocus = 3*KMicroSecPerSec; |
|
1164 |
|
1165 TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue ); |
|
1166 *ptr = timerPeriod3; |
|
1167 break; |
|
1168 } |
|
1169 // ----------------------------------------------------- |
|
1170 // Zoom steps. |
|
1171 case ECamPsiMaxOpticalZoomSteps: |
|
1172 { |
|
1173 // Default constructor defined to initialize |
|
1174 // all fields to KErrNotSupported. See CamPSI.h. |
|
1175 TCamMaxZoomSteps optSteps; |
|
1176 |
|
1177 // No optical zoom steps supported => nothing more to set. |
|
1178 |
|
1179 TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue ); |
|
1180 *ptr = optSteps; |
|
1181 break; |
|
1182 } |
|
1183 case ECamPsiMaxZoomSteps: |
|
1184 { |
|
1185 TCamMaxZoomSteps digSteps; |
|
1186 |
|
1187 // the order the values read are exactly in the order defined in |
|
1188 // TCamMaxZoomSteps |
|
1189 |
|
1190 uiConfigManager->SupportedMaxZoomStepsL( zoomValues ); |
|
1191 |
|
1192 // all the values if they are supported or not will be run-time |
|
1193 TInt count = zoomValues.Count()-1; |
|
1194 TInt i = 0; |
|
1195 if ( zoomValues.Count() ) |
|
1196 { |
|
1197 digSteps.iMaxPhotoStepW9MP = zoomValues[Min(count,i++)]; |
|
1198 digSteps.iMaxPhotoStepW6MP = zoomValues[Min(count,i++)]; |
|
1199 digSteps.iMaxPhotoStep12MP = zoomValues[Min(count,i++)]; |
|
1200 digSteps.iMaxPhotoStep8MP = zoomValues[Min(count,i++)]; |
|
1201 digSteps.iMaxPhotoStep5MP = zoomValues[Min(count,i++)]; |
|
1202 digSteps.iMaxPhotoStep3MP = zoomValues[Min(count,i++)]; |
|
1203 digSteps.iMaxPhotoStep2MP = zoomValues[Min(count,i++)]; |
|
1204 digSteps.iMaxPhotoStep1_3MP = zoomValues[Min(count,i++)]; |
|
1205 digSteps.iMaxPhotoStep1MP = zoomValues[Min(count,i++)]; |
|
1206 digSteps.iMaxPhotoStep0_8MP = zoomValues[Min(count,i++)]; |
|
1207 digSteps.iMaxPhotoStepSVGA = zoomValues[Min(count,i++)]; |
|
1208 digSteps.iMaxPhotoStepVGA = zoomValues[Min(count,i++)]; |
|
1209 |
|
1210 |
|
1211 digSteps.iMaxVideoStepHD = zoomValues[Min(count,i++)]; |
|
1212 digSteps.iMaxVideoStepWVGA = zoomValues[Min(count,i++)]; |
|
1213 digSteps.iMaxVideoStepNHD = zoomValues[Min(count,i++)]; |
|
1214 digSteps.iMaxVideoStepVGA = zoomValues[Min(count,i++)]; |
|
1215 digSteps.iMaxVideoStepQVGA = zoomValues[Min(count,i++)]; |
|
1216 digSteps.iMaxVideoStepCIF = zoomValues[Min(count,i++)]; |
|
1217 digSteps.iMaxVideoStepQCIF = zoomValues[Min(count,i++)]; |
|
1218 digSteps.iMaxVideoStepSQCIF = zoomValues[Min(count,i++)]; |
|
1219 digSteps.iMax2ndCamPhotoStep = zoomValues[Min(count,i++)]; |
|
1220 digSteps.iMax2ndCamVideoStepCIF = zoomValues[Min(count,i++)]; |
|
1221 digSteps.iMax2ndCamVideoStepQCIF = zoomValues[Min(count,i++)]; |
|
1222 digSteps.iMax2ndCamVideoStepSQCIF = zoomValues[Min(count,i++)]; |
|
1223 } |
|
1224 else |
|
1225 { |
|
1226 User::Leave( KErrNotSupported ); |
|
1227 } |
|
1228 TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue ); |
|
1229 *ptr = digSteps; |
|
1230 break; |
|
1231 } |
|
1232 case ECamPsiMaxExtendedZoomSteps: |
|
1233 { |
|
1234 TCamMaxZoomSteps extSteps; |
|
1235 |
|
1236 // the order the values read are exactly in the order defined in |
|
1237 // TCamMaxZoomSteps |
|
1238 |
|
1239 uiConfigManager->SupportedMaxExtendedZoomStepsL( zoomValues ); |
|
1240 |
|
1241 // TODO: some kind of check to see if there are all possible values in |
|
1242 // the array that we ask from config manager. |
|
1243 TInt count = zoomValues.Count()-1; |
|
1244 TInt i = 0; |
|
1245 if ( zoomValues.Count() > 0 ) |
|
1246 { |
|
1247 extSteps.iMaxPhotoStepW9MP = zoomValues[Min(count,i++)]; |
|
1248 extSteps.iMaxPhotoStepW6MP = zoomValues[Min(count,i++)]; |
|
1249 extSteps.iMaxPhotoStep12MP = zoomValues[Min(count,i++)]; //KMaxPhoto12MPExtZoomStep; |
|
1250 extSteps.iMaxPhotoStep8MP = zoomValues[Min(count,i++)]; //KMaxPhoto8MPExtZoomStep; |
|
1251 extSteps.iMaxPhotoStep5MP = zoomValues[Min(count,i++)]; //KMaxPhoto5MPExtZoomStep; |
|
1252 extSteps.iMaxPhotoStep3MP = zoomValues[Min(count,i++)]; //KMaxPhoto3MPExtZoomStep; |
|
1253 extSteps.iMaxPhotoStep2MP = zoomValues[Min(count,i++)]; //KMaxPhoto2MPExtZoomStep; |
|
1254 extSteps.iMaxPhotoStep1_3MP = zoomValues[Min(count,i++)]; //KMaxPhoto1_3MPExtZoomStep; |
|
1255 extSteps.iMaxPhotoStep1MP = zoomValues[Min(count,i++)]; //KMaxPhoto1MPExtZoomStep; |
|
1256 extSteps.iMaxPhotoStep0_8MP = zoomValues[Min(count,i++)]; //KMaxPhoto0_8MPExtZoomStep; |
|
1257 extSteps.iMaxPhotoStepSVGA = zoomValues[Min(count,i++)]; |
|
1258 extSteps.iMaxPhotoStepVGA = zoomValues[Min(count,i++)]; //KMaxPhotoVGAExtZoomStep; |
|
1259 } |
|
1260 else |
|
1261 { |
|
1262 User::Leave( KErrNotSupported ); |
|
1263 } |
|
1264 TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue ); |
|
1265 *ptr = extSteps; |
|
1266 break; |
|
1267 } |
|
1268 // ----------------------------------------------------- |
|
1269 // Zoom appearance |
|
1270 case ECamPsiZoomBarLAF: |
|
1271 { |
|
1272 const TRgb KZoomColourDig = TRgb( 255, 140, 1 ); |
|
1273 const TRgb KZoomColourExt = TRgb( 255, 0, 0 ); |
|
1274 |
|
1275 TCamZoomLAF zoomLAF; |
|
1276 uiConfigManager->SupportedLAFZoomBarL( zoomValues ); |
|
1277 |
|
1278 if ( zoomValues.Count() > 0 ) |
|
1279 { |
|
1280 // Time per zoom tick in milliseconds |
|
1281 zoomLAF.iZoomSpeedDig = zoomValues[0]; //KZoomSpeedDig; |
|
1282 // No of zoom steps per tick |
|
1283 zoomLAF.iZoomStepsDig = zoomValues[2]; //KZoomStepsDig; |
|
1284 |
|
1285 // Time per ext zoom tick in milliseconds |
|
1286 zoomLAF.iZoomSpeedExt = zoomValues[1]; //KZoomSpeedExt; |
|
1287 // No of ext zoom steps per tick |
|
1288 zoomLAF.iZoomStepsExt = zoomValues[3]; //KZoomStepsExt; |
|
1289 |
|
1290 zoomLAF.iSecondCameraZoomSteps = zoomValues[4]; //K2ndCamZoomStepSize |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 User::Leave( KErrNotSupported ); |
|
1295 } |
|
1296 |
|
1297 // Colour of optical zoom in zoom bar |
|
1298 zoomLAF.iZoomColourDig = KZoomColourDig; |
|
1299 // Colour of optical zoom in zoom bar |
|
1300 zoomLAF.iZoomColourExt = KZoomColourExt; |
|
1301 |
|
1302 TCamZoomLAFPckg* ptr = static_cast<TCamZoomLAFPckg*>( aValue ); |
|
1303 *ptr = zoomLAF; |
|
1304 break; |
|
1305 } |
|
1306 // ----------------------------------------------------- |
|
1307 // Exposure compensation values |
|
1308 case ECamPsiEVCompSliderInfo: |
|
1309 { |
|
1310 TCamEvCompRange evComp; |
|
1311 |
|
1312 evComp.iMinValue = KEVCompMinVal; |
|
1313 evComp.iMaxValue = KEVCompMaxVal; |
|
1314 evComp.iStepsPerUnit = KEVCompStepsPerUnit; |
|
1315 |
|
1316 TCamEVCompPckg* ptr = static_cast<TCamEVCompPckg*>( aValue ); |
|
1317 *ptr = evComp; |
|
1318 break; |
|
1319 } |
|
1320 // ----------------------------------------------------- |
|
1321 default: |
|
1322 { |
|
1323 return KErrNotSupported; |
|
1324 } |
|
1325 // ----------------------------------------------------- |
|
1326 } |
|
1327 CleanupStack::PopAndDestroy( &zoomValues ); |
|
1328 return KErrNone; |
|
1329 } |
|
1330 |
|
1331 |
|
1332 // --------------------------------------------------------------------------- |
|
1333 // CamUtility::ResourceOrientationID |
|
1334 // Returns the resource for the given ID, based on the current Orientation |
|
1335 // --------------------------------------------------------------------------- |
|
1336 // |
|
1337 TInt |
|
1338 CamUtility::ResourceOrientationID( TInt aDefaultResourceID ) |
|
1339 { |
|
1340 TCamOrientation orientation; |
|
1341 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
1342 |
|
1343 // Make sure the resource ID is in a valid range |
|
1344 TBool inValidRange = Rng( 0, aDefaultResourceID, R_CAM_LAST_RESOURCE_ID ); |
|
1345 __ASSERT_DEBUG( inValidRange, CamPanic(ECamPanicInvalidResource) ); |
|
1346 |
|
1347 // This should never happen, but we may be being passed the original resource number |
|
1348 if( !inValidRange ) { return aDefaultResourceID; } |
|
1349 |
|
1350 // Get the current orientation |
|
1351 // If we don't have the AppUI, |
|
1352 // assume the app is starting up and use the default orientation |
|
1353 if( appUi ) { orientation = appUi->CamOrientation(); } |
|
1354 else { orientation = ECamOrientationDefault; } |
|
1355 |
|
1356 __ASSERT_DEBUG( (ECamOrientationTotal > orientation), CamPanic(ECamPanicBadIndex) ); |
|
1357 |
|
1358 return KRoidLookup[aDefaultResourceID][orientation]; |
|
1359 } |
|
1360 |
|
1361 |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // MapLightSensitivity2IsoValueL |
|
1364 // Maps each general light sensitivity id (TCamLightSensitivityId) |
|
1365 // to a product specific ISO rating. |
|
1366 // --------------------------------------------------------------------------- |
|
1367 // |
|
1368 TInt |
|
1369 CamUtility::MapLightSensitivity2IsoValueL( TCamLightSensitivityId aLightSensitivityId, RArray<TInt>& aSupportedValues ) |
|
1370 { |
|
1371 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
1372 CCameraUiConfigManager* UiConfigManager = appUi->AppController().UiConfigManagerPtr(); |
|
1373 |
|
1374 aSupportedValues.Sort(); |
|
1375 TInt count = aSupportedValues.Count(); |
|
1376 if ( count == 0 ) |
|
1377 { |
|
1378 return ECamIsoRateAuto; |
|
1379 } |
|
1380 if ( UiConfigManager->IsExtendedLightSensitivitySupported() ) |
|
1381 { |
|
1382 // Make sure there is enough supported ISO values for extended light sensitivity |
|
1383 // first value is 0 which means automatic, there should be 5 or more other values |
|
1384 TBool enoughSupported = (count > 5); |
|
1385 if ( !enoughSupported ) { |
|
1386 CamPanic(ECamPanicNotEnoughISOValuesSupported); |
|
1387 } |
|
1388 switch ( aLightSensitivityId ) |
|
1389 { |
|
1390 // Supports: 100, 200, 400, 800, 1600, 3200. |
|
1391 case ECamLightSensitivityLow: return aSupportedValues[1]; |
|
1392 case ECamLightSensitivityLowMed: return aSupportedValues[2]; |
|
1393 case ECamLightSensitivityMed: return aSupportedValues[3]; |
|
1394 case ECamLightSensitivityMedHigh: return aSupportedValues[4]; |
|
1395 case ECamLightSensitivityHigh: return aSupportedValues[5]; |
|
1396 default: return ECamIsoRateAuto; |
|
1397 } |
|
1398 } |
|
1399 else |
|
1400 { |
|
1401 switch ( aLightSensitivityId ) |
|
1402 { |
|
1403 case ECamLightSensitivityLow: return aSupportedValues[0]; |
|
1404 case ECamLightSensitivityMed: return aSupportedValues[TInt(count/2)]; |
|
1405 case ECamLightSensitivityHigh: return aSupportedValues[count-1]; |
|
1406 default: return ECamIsoRateAuto; |
|
1407 } |
|
1408 } |
|
1409 } |
|
1410 |
|
1411 |
|
1412 // --------------------------------------------------------------------------- |
|
1413 // MapSharpnessId2SharpnessValueL |
|
1414 // Maps each general sharpness value (TCamImageSharpnessId) |
|
1415 // to a product specific value. |
|
1416 // --------------------------------------------------------------------------- |
|
1417 // |
|
1418 TInt |
|
1419 CamUtility::MapSharpnessId2SharpnessValueL( TCamImageSharpnessId aSharpnessId ) |
|
1420 { |
|
1421 TInt sharpnessValue = 0; |
|
1422 RArray<TInt> supportedValues; |
|
1423 CleanupClosePushL( supportedValues ); |
|
1424 |
|
1425 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
1426 if ( appUi && appUi->AppController().UiConfigManagerPtr() ) |
|
1427 { |
|
1428 appUi->AppController().UiConfigManagerPtr()->SupportedSharpnessSettingsL( |
|
1429 supportedValues ); |
|
1430 } |
|
1431 |
|
1432 if ( supportedValues.Count() > 0 ) |
|
1433 { |
|
1434 switch( aSharpnessId ) |
|
1435 { |
|
1436 case ECamImageSharpnessHard: |
|
1437 sharpnessValue = supportedValues[supportedValues.Count()-1]; |
|
1438 break; |
|
1439 case ECamImageSharpnessSoft: |
|
1440 sharpnessValue = supportedValues[0]; |
|
1441 break; |
|
1442 case ECamImageSharpnessNorm: // <<fall through>> |
|
1443 default: |
|
1444 sharpnessValue = supportedValues[1]; // normal value = 0 |
|
1445 break; |
|
1446 } |
|
1447 } |
|
1448 else |
|
1449 { |
|
1450 User::Leave( KErrNotSupported ); |
|
1451 } |
|
1452 CleanupStack::PopAndDestroy( &supportedValues ); |
|
1453 |
|
1454 return sharpnessValue; |
|
1455 } |
|
1456 |
|
1457 |
|
1458 // --------------------------------------------------------------------------- |
|
1459 // CamUtility::MapVideoQualityToViewFinderRes |
|
1460 // Return resource id for viewfinder resolution for primary camera |
|
1461 // --------------------------------------------------------------------------- |
|
1462 // |
|
1463 TInt |
|
1464 CamUtility::MapVideoQualityToViewFinderRes( TCamVideoResolution aResolution ) |
|
1465 { |
|
1466 PRINT1( _L("Camera => CamUtility::MapVideoQualityToViewFinderRes res (%d)"), aResolution ) |
|
1467 switch( aResolution ) |
|
1468 { |
|
1469 case ECamVideoResolutionVGA: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER; |
|
1470 case ECamVideoResolutionQVGA: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER; |
|
1471 case ECamVideoResolutionQCIF: return R_CAM_VIEWFINDER_RECT_CIF_CAMCORDER_ADJUSTED; |
|
1472 default: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER; |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 #endif // CAMERAAPP_PLUGIN_BUILD |
|
1477 // --------------------------------------------------------------------------- |
|
1478 // CamUtility::GetCommonPsiInt |
|
1479 // Allows retrieval of product specific information (TInt) |
|
1480 // --------------------------------------------------------------------------- |
|
1481 // |
|
1482 TInt CamUtility::GetCommonPsiInt( TCamPsiKey aKey, TInt& aValue ) |
|
1483 { |
|
1484 aValue = KErrNotSupported; |
|
1485 |
|
1486 switch ( aKey ) |
|
1487 { |
|
1488 case ECamPsiOrientation: { aValue = CAknAppUiBase::EAppUiOrientationLandscape; break; } |
|
1489 case ECamPsiPrimaryCameraOrientation: { aValue = CAknAppUiBase::EAppUiOrientationLandscape; break; } |
|
1490 case ECamPsiSecondaryCameraOrientation: { aValue = CAknAppUiBase::EAppUiOrientationPortrait; break; } |
|
1491 case ECamPsiEditingOrientation: { aValue = CAknAppUiBase::EAppUiOrientationPortrait; break; } |
|
1492 |
|
1493 default: |
|
1494 { |
|
1495 return KErrNotSupported; |
|
1496 } |
|
1497 } |
|
1498 return KErrNone; |
|
1499 } |
|
1500 |
|
1501 |
|
1502 // ----------------------------------------------------------------------------- |
|
1503 // CamUtility::IsQwertyOpen |
|
1504 // ----------------------------------------------------------------------------- |
|
1505 // |
|
1506 TBool CamUtility::IsQwertyOpen() |
|
1507 { |
|
1508 TBool retvalue = EFalse; |
|
1509 TInt status = 0; |
|
1510 TInt err = RProperty::Get( KCRUidAvkon, KAknQwertyInputModeActive, status ); |
|
1511 PRINT2(_L("Camera <> CamUtility::IsQwertyOpen err%d status%d"),err, status); |
|
1512 if ( !err && status ) |
|
1513 { |
|
1514 retvalue = ETrue; |
|
1515 } |
|
1516 return retvalue; |
|
1517 } |
|
1518 |
|
1519 |
|
1520 // ----------------------------------------------------------------------------- |
|
1521 // CamUtility::ViewfinderLayout |
|
1522 // |
|
1523 // Get resolution from CCamAppController::GetCurrentVideoResolution() |
|
1524 // or CCamAppController::GetCurrentImageResolution(). |
|
1525 // |
|
1526 // ----------------------------------------------------------------------------- |
|
1527 // |
|
1528 TRect |
|
1529 CamUtility::ViewfinderLayout( TCamCameraMode aMode, |
|
1530 TInt aResolution ) |
|
1531 { |
|
1532 PRINT1( _L("Camera => CamUtility::ViewfinderLayout - resolution[%d]"), aResolution ); |
|
1533 |
|
1534 TAknWindowLineLayout l = IsNhdDevice() |
|
1535 ? ViewfinderLayoutTouch(aMode, aResolution) |
|
1536 : ViewfinderLayoutNonTouch(aMode, aResolution); |
|
1537 |
|
1538 TRect screenRect; |
|
1539 if ( Layout_Meta_Data::IsLandscapeOrientation() || IsNhdDevice() ) |
|
1540 { |
|
1541 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect ); |
|
1546 } |
|
1547 |
|
1548 TAknLayoutRect vfLayoutRect; |
|
1549 vfLayoutRect.LayoutRect( screenRect, l ); |
|
1550 TRect vfRect( vfLayoutRect.Rect() ); |
|
1551 |
|
1552 PRINT4( _L("Camera <= CamUtility::ViewfinderLayout - rect[x:%d y:%d w:%d h:%d]"), |
|
1553 vfRect.iTl.iX, vfRect.iTl.iY, vfRect.Width(), vfRect.Height() ); |
|
1554 |
|
1555 return vfRect; |
|
1556 } |
|
1557 |
|
1558 |
|
1559 // ----------------------------------------------------------------------------- |
|
1560 // CamUtility::ViewfinderLayoutTouch |
|
1561 // |
|
1562 // ----------------------------------------------------------------------------- |
|
1563 // |
|
1564 TAknWindowLineLayout |
|
1565 CamUtility::ViewfinderLayoutTouch( TCamCameraMode aMode, |
|
1566 TInt aResolution ) |
|
1567 { |
|
1568 TInt variant = Layout_Meta_Data::IsLandscapeOrientation(); |
|
1569 |
|
1570 // Default to 4:3 full screen |
|
1571 TAknWindowLineLayout l = |
|
1572 AknLayoutScalable_Apps::cam4_image_uncrop_pane( variant ); |
|
1573 |
|
1574 // ------------------------------------------------------- |
|
1575 // Video mode |
|
1576 if ( ECamControllerVideo == aMode ) |
|
1577 { |
|
1578 switch( aResolution ) |
|
1579 { |
|
1580 case ECamVideoResolutionQCIF: |
|
1581 case ECamVideoResolutionCIF: |
|
1582 { |
|
1583 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - QCIF/CIF video resolution") ); |
|
1584 l = AknLayoutScalable_Apps::video4_image_uncrop_cif_pane( variant ); |
|
1585 break; |
|
1586 } |
|
1587 case ECamVideoResolutionNHD: |
|
1588 case ECamVideoResolutionHD: |
|
1589 { |
|
1590 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - nHD/HD video resolution") ); |
|
1591 l = AknLayoutScalable_Apps::video4_image_uncrop_nhd_pane( variant ); |
|
1592 break; |
|
1593 } |
|
1594 default: |
|
1595 { |
|
1596 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 4:3 video resolution") ); |
|
1597 // All other video resolutions are expected to |
|
1598 // have 4:3 aspect ratio |
|
1599 l = AknLayoutScalable_Apps::video4_image_uncrop_vga_pane( variant ); |
|
1600 break; |
|
1601 } |
|
1602 } |
|
1603 } |
|
1604 // ------------------------------------------------------- |
|
1605 // Image mode |
|
1606 else if ( ECamControllerImage == aMode ) |
|
1607 { |
|
1608 switch( aResolution ) |
|
1609 { |
|
1610 case ECamPhotoSizeW9MP: |
|
1611 case ECamPhotoSizeW6MP: |
|
1612 { |
|
1613 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 16:9 still image resolution") ); |
|
1614 l = AknLayoutScalable_Apps::video4_image_uncrop_nhd_pane( variant ); |
|
1615 break; |
|
1616 } |
|
1617 default: |
|
1618 { |
|
1619 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 4:3 still image resolution") ); |
|
1620 l = AknLayoutScalable_Apps::cam4_image_uncrop_pane( variant ); |
|
1621 break; |
|
1622 } |
|
1623 } |
|
1624 } |
|
1625 // ------------------------------------------------------- |
|
1626 |
|
1627 return l; |
|
1628 } |
|
1629 |
|
1630 |
|
1631 |
|
1632 // --------------------------------------------------------------------------- |
|
1633 // CamUtility::ViewfinderLayoutNonTouch |
|
1634 // --------------------------------------------------------------------------- |
|
1635 // |
|
1636 TAknWindowLineLayout |
|
1637 CamUtility::ViewfinderLayoutNonTouch( TCamCameraMode aMode, |
|
1638 TInt aResolution ) |
|
1639 { |
|
1640 TInt variant = Layout_Meta_Data::IsLandscapeOrientation() ? 0 : 3; |
|
1641 |
|
1642 TAknWindowLineLayout l = |
|
1643 AknLayoutScalable_Apps::cam6_image_uncrop_pane( variant ); |
|
1644 |
|
1645 // ------------------------------------------------------- |
|
1646 // Video mode |
|
1647 if ( ECamControllerVideo == aMode ) |
|
1648 { |
|
1649 switch( aResolution ) |
|
1650 { |
|
1651 case ECamVideoResolutionQCIF: |
|
1652 case ECamVideoResolutionCIF: |
|
1653 { |
|
1654 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - QCIF/CIF video resolution") ); |
|
1655 l = AknLayoutScalable_Apps::vid6_image_uncrop_cif_pane( variant ); |
|
1656 break; |
|
1657 } |
|
1658 case ECamVideoResolutionNHD: |
|
1659 case ECamVideoResolutionHD: |
|
1660 { |
|
1661 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - nHD/HD video resolution") ); |
|
1662 l = AknLayoutScalable_Apps::vid6_image_uncrop_nhd_pane( variant ); |
|
1663 break; |
|
1664 } |
|
1665 case ECamVideoResolutionWVGA: |
|
1666 { |
|
1667 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - WVGA video resolution") ); |
|
1668 l = AknLayoutScalable_Apps::vid6_image_uncrop_wvga_pane( variant ); |
|
1669 break; |
|
1670 } |
|
1671 default: |
|
1672 { |
|
1673 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 4:3 video resolution") ); |
|
1674 // All other video resolutions are expected to |
|
1675 // have 4:3 aspect ratio |
|
1676 l = AknLayoutScalable_Apps::vid6_image_uncrop_vga_pane( variant ); |
|
1677 break; |
|
1678 } |
|
1679 } |
|
1680 } |
|
1681 // ------------------------------------------------------- |
|
1682 // Image mode |
|
1683 else |
|
1684 { |
|
1685 switch( aResolution ) |
|
1686 { |
|
1687 case ECamPhotoSizeW9MP: |
|
1688 case ECamPhotoSizeW6MP: |
|
1689 { |
|
1690 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 16:9 still image resolution") ); |
|
1691 l = AknLayoutScalable_Apps::vid6_image_uncrop_nhd_pane( variant ); |
|
1692 } |
|
1693 default: |
|
1694 { |
|
1695 PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 4:3 still image resolution") ); |
|
1696 l = AknLayoutScalable_Apps::cam6_image_uncrop_pane( variant ); |
|
1697 break; |
|
1698 } |
|
1699 } |
|
1700 } |
|
1701 // ------------------------------------------------------- |
|
1702 |
|
1703 return l; |
|
1704 } |
|
1705 |
|
1706 |
|
1707 // End of File |
|
1708 |