24
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: 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_SET_USER_DEFAULT ) );
|
|
1033 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_SCENEBASE_DATA ) );
|
|
1034 |
if ( configManager->IsFlashModeSupported() )
|
|
1035 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_FLASH_DATA ) );
|
|
1036 |
if ( configManager->IsWhiteBalanceFeatureSupported() )
|
|
1037 |
User::LeaveIfError( aArray.Append(
|
|
1038 |
R_CAM_PHOTO_USER_SCENE_SETUP_LIST_WHITEBALANCE_DATA ) );
|
|
1039 |
if ( configManager->IsEVSupported() )
|
|
1040 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_EV_DATA2 ) );
|
|
1041 |
|
|
1042 |
if ( configManager->IsColorToneFeatureSupported() )
|
|
1043 |
User::LeaveIfError( aArray.Append(
|
|
1044 |
R_CAM_PHOTO_USER_SCENE_SETUP_LIST_COLOUREFFECT_DATA ) );
|
|
1045 |
if ( configManager->IsISOSupported() )
|
|
1046 |
{
|
|
1047 |
if ( configManager->IsExtendedLightSensitivitySupported() )
|
|
1048 |
{
|
|
1049 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_EXTENDED_LIGHTSENSITIVITY_DATA ) );
|
|
1050 |
}
|
|
1051 |
else {
|
|
1052 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_LIGHTSENSITIVITY_DATA ) );
|
|
1053 |
}
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
if ( configManager->IsSharpnessFeatureSupported() )
|
|
1057 |
User::LeaveIfError( aArray.Append(
|
|
1058 |
R_CAM_PHOTO_USER_SCENE_SETUP_LIST_IMAGESHARPNESS_DATA ) );
|
|
1059 |
|
|
1060 |
if ( configManager->IsContrastSupported() )
|
|
1061 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_CONTRAST_DATA ) );
|
|
1062 |
|
|
1063 |
User::LeaveIfError( aArray.Append( R_CAM_PHOTO_USER_SCENE_SETUP_LIST_RESET_DATA ) );
|
|
1064 |
break;
|
|
1065 |
}
|
|
1066 |
// -----------------------------------------------------
|
|
1067 |
default:
|
|
1068 |
{
|
|
1069 |
return KErrNotSupported;
|
|
1070 |
}
|
|
1071 |
}
|
|
1072 |
return KErrNone;
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
// ---------------------------------------------------------------------------
|
|
1076 |
// CamUtility::GetPsiAnyL
|
|
1077 |
// Allows retrieval of product specific information (TAny)
|
|
1078 |
// ---------------------------------------------------------------------------
|
|
1079 |
//
|
|
1080 |
TInt CamUtility::GetPsiAnyL( TCamPsiKey aKey, TAny* aValue )
|
|
1081 |
{
|
|
1082 |
CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
|
|
1083 |
CCameraUiConfigManager* uiConfigManager = appUi->AppController().UiConfigManagerPtr();
|
|
1084 |
|
|
1085 |
RArray<TInt> zoomValues;
|
|
1086 |
CleanupClosePushL( zoomValues );
|
|
1087 |
zoomValues.Reset();
|
|
1088 |
|
|
1089 |
typedef TPckgBuf<TCamMaxZoomSteps> TCamZoomStepPckg;
|
|
1090 |
typedef TPckgBuf<TSelfTimerSetting> TCamTimerSetPckg;
|
|
1091 |
typedef TPckgBuf<TCamZoomLAF> TCamZoomLAFPckg;
|
|
1092 |
typedef TPckgBuf<TCamEvCompRange> TCamEVCompPckg;
|
|
1093 |
|
|
1094 |
switch ( aKey )
|
|
1095 |
{
|
|
1096 |
// -----------------------------------------------------
|
|
1097 |
// Self timer periods
|
|
1098 |
case ECamPsiSelfTimerPeriod1:
|
|
1099 |
{
|
|
1100 |
// Default constructor assigns KErrNotSupported to all fields.
|
|
1101 |
// See CamPSI.h.
|
|
1102 |
TSelfTimerSetting timerPeriod1;
|
|
1103 |
|
|
1104 |
// First period is at 2-seconds remaining, "always on"
|
|
1105 |
timerPeriod1.iThreshold [0] = 2*KMicroSecPerSec;
|
|
1106 |
timerPeriod1.iFlashPeriod[0] = KMicSecInQuartSec;// KMaxTInt;
|
|
1107 |
timerPeriod1.iBeepPeriod [0] = KMicSecInHalfSec;// KMaxTInt;
|
|
1108 |
|
|
1109 |
// There are no other periods
|
|
1110 |
|
|
1111 |
// Autofocus triggered on "2-seconds remaining"
|
|
1112 |
timerPeriod1.iAutoFocus = 2*KMicroSecPerSec;
|
|
1113 |
|
|
1114 |
TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue );
|
|
1115 |
*ptr = timerPeriod1;
|
|
1116 |
break;
|
|
1117 |
}
|
|
1118 |
case ECamPsiSelfTimerPeriod2:
|
|
1119 |
{
|
|
1120 |
TSelfTimerSetting timerPeriod2;
|
|
1121 |
|
|
1122 |
// First period is at 10-seconds until capture, flashing once every second.
|
|
1123 |
timerPeriod2.iThreshold [0] = 10*KMicroSecPerSec;
|
|
1124 |
timerPeriod2.iFlashPeriod[0] = KMicSecInHalfSec; // 500ms on/500ms off
|
|
1125 |
timerPeriod2.iBeepPeriod [0] = KMicroSecPerSec; // Beep every second
|
|
1126 |
|
|
1127 |
// Second period starts at 3-seconds until capture, flashing twice every second
|
|
1128 |
timerPeriod2.iThreshold [1] = 2*KMicroSecPerSec;
|
|
1129 |
timerPeriod2.iFlashPeriod[1] = KMicSecInQuartSec; // 250ms on/250ms off
|
|
1130 |
timerPeriod2.iBeepPeriod [1] = KMicSecInHalfSec; // Beep twice every second
|
|
1131 |
|
|
1132 |
// Third period is not supported
|
|
1133 |
timerPeriod2.iThreshold [2] = 0*KMicroSecPerSec;
|
|
1134 |
timerPeriod2.iFlashPeriod[2] = KMaxTInt;
|
|
1135 |
timerPeriod2.iBeepPeriod [2] = KMaxTInt;
|
|
1136 |
|
|
1137 |
// Autofocus triggered on "3-seconds remaining"
|
|
1138 |
timerPeriod2.iAutoFocus = 3*KMicroSecPerSec;
|
|
1139 |
|
|
1140 |
TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue );
|
|
1141 |
*ptr = timerPeriod2;
|
|
1142 |
break;
|
|
1143 |
}
|
|
1144 |
case ECamPsiSelfTimerPeriod3:
|
|
1145 |
{
|
|
1146 |
TSelfTimerSetting timerPeriod3;
|
|
1147 |
|
|
1148 |
// First period is at 20-seconds until capture, flashing once every second.
|
|
1149 |
timerPeriod3.iThreshold [0] = 20*KMicroSecPerSec;
|
|
1150 |
timerPeriod3.iFlashPeriod[0] = KMicSecInHalfSec; // 500ms on/500ms off
|
|
1151 |
timerPeriod3.iBeepPeriod [0] = KMicroSecPerSec; // Beep every second
|
|
1152 |
|
|
1153 |
// Second period starts at 3-seconds until capture, flashing twice every second
|
|
1154 |
timerPeriod3.iThreshold [1] = 2*KMicroSecPerSec;
|
|
1155 |
timerPeriod3.iFlashPeriod[1] = KMicSecInQuartSec; // 250ms on/250ms off
|
|
1156 |
timerPeriod3.iBeepPeriod [1] = KMicSecInHalfSec; // Beep twice every second
|
|
1157 |
|
|
1158 |
// Third period is not supported
|
|
1159 |
timerPeriod3.iThreshold [2] = 0*KMicroSecPerSec;
|
|
1160 |
timerPeriod3.iFlashPeriod[2] = KMaxTInt;
|
|
1161 |
timerPeriod3.iBeepPeriod [2] = KMaxTInt;
|
|
1162 |
|
|
1163 |
// Autofocus triggered on "3-seconds remaining"
|
|
1164 |
timerPeriod3.iAutoFocus = 3*KMicroSecPerSec;
|
|
1165 |
|
|
1166 |
TCamTimerSetPckg* ptr = static_cast<TCamTimerSetPckg*>( aValue );
|
|
1167 |
*ptr = timerPeriod3;
|
|
1168 |
break;
|
|
1169 |
}
|
|
1170 |
// -----------------------------------------------------
|
|
1171 |
// Zoom steps.
|
|
1172 |
case ECamPsiMaxOpticalZoomSteps:
|
|
1173 |
{
|
|
1174 |
// Default constructor defined to initialize
|
|
1175 |
// all fields to KErrNotSupported. See CamPSI.h.
|
|
1176 |
TCamMaxZoomSteps optSteps;
|
|
1177 |
|
|
1178 |
// No optical zoom steps supported => nothing more to set.
|
|
1179 |
|
|
1180 |
TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue );
|
|
1181 |
*ptr = optSteps;
|
|
1182 |
break;
|
|
1183 |
}
|
|
1184 |
case ECamPsiMaxZoomSteps:
|
|
1185 |
{
|
|
1186 |
TCamMaxZoomSteps digSteps;
|
|
1187 |
|
|
1188 |
// the order the values read are exactly in the order defined in
|
|
1189 |
// TCamMaxZoomSteps
|
|
1190 |
|
|
1191 |
uiConfigManager->SupportedMaxZoomStepsL( zoomValues );
|
|
1192 |
|
|
1193 |
// all the values if they are supported or not will be run-time
|
|
1194 |
TInt count = zoomValues.Count()-1;
|
|
1195 |
TInt i = 0;
|
|
1196 |
if ( zoomValues.Count() )
|
|
1197 |
{
|
|
1198 |
digSteps.iMaxPhotoStepW9MP = zoomValues[Min(count,i++)];
|
|
1199 |
digSteps.iMaxPhotoStepW6MP = zoomValues[Min(count,i++)];
|
|
1200 |
digSteps.iMaxPhotoStep12MP = zoomValues[Min(count,i++)];
|
|
1201 |
digSteps.iMaxPhotoStep8MP = zoomValues[Min(count,i++)];
|
|
1202 |
digSteps.iMaxPhotoStep5MP = zoomValues[Min(count,i++)];
|
|
1203 |
digSteps.iMaxPhotoStep3MP = zoomValues[Min(count,i++)];
|
|
1204 |
digSteps.iMaxPhotoStep2MP = zoomValues[Min(count,i++)];
|
|
1205 |
digSteps.iMaxPhotoStep1_3MP = zoomValues[Min(count,i++)];
|
|
1206 |
digSteps.iMaxPhotoStep1MP = zoomValues[Min(count,i++)];
|
|
1207 |
digSteps.iMaxPhotoStep0_8MP = zoomValues[Min(count,i++)];
|
|
1208 |
digSteps.iMaxPhotoStepSVGA = zoomValues[Min(count,i++)];
|
|
1209 |
digSteps.iMaxPhotoStepVGA = zoomValues[Min(count,i++)];
|
|
1210 |
|
|
1211 |
|
|
1212 |
digSteps.iMaxVideoStepHD = zoomValues[Min(count,i++)];
|
|
1213 |
digSteps.iMaxVideoStepWVGA = zoomValues[Min(count,i++)];
|
|
1214 |
digSteps.iMaxVideoStepNHD = zoomValues[Min(count,i++)];
|
|
1215 |
digSteps.iMaxVideoStepVGA = zoomValues[Min(count,i++)];
|
|
1216 |
digSteps.iMaxVideoStepQVGA = zoomValues[Min(count,i++)];
|
|
1217 |
digSteps.iMaxVideoStepCIF = zoomValues[Min(count,i++)];
|
|
1218 |
digSteps.iMaxVideoStepQCIF = zoomValues[Min(count,i++)];
|
|
1219 |
digSteps.iMaxVideoStepSQCIF = zoomValues[Min(count,i++)];
|
|
1220 |
digSteps.iMax2ndCamPhotoStep = zoomValues[Min(count,i++)];
|
|
1221 |
digSteps.iMax2ndCamVideoStepCIF = zoomValues[Min(count,i++)];
|
|
1222 |
digSteps.iMax2ndCamVideoStepQCIF = zoomValues[Min(count,i++)];
|
|
1223 |
digSteps.iMax2ndCamVideoStepSQCIF = zoomValues[Min(count,i++)];
|
|
1224 |
}
|
|
1225 |
else
|
|
1226 |
{
|
|
1227 |
User::Leave( KErrNotSupported );
|
|
1228 |
}
|
|
1229 |
TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue );
|
|
1230 |
*ptr = digSteps;
|
|
1231 |
break;
|
|
1232 |
}
|
|
1233 |
case ECamPsiMaxExtendedZoomSteps:
|
|
1234 |
{
|
|
1235 |
TCamMaxZoomSteps extSteps;
|
|
1236 |
|
|
1237 |
// the order the values read are exactly in the order defined in
|
|
1238 |
// TCamMaxZoomSteps
|
|
1239 |
|
|
1240 |
uiConfigManager->SupportedMaxExtendedZoomStepsL( zoomValues );
|
|
1241 |
|
|
1242 |
// TODO: some kind of check to see if there are all possible values in
|
|
1243 |
// the array that we ask from config manager.
|
|
1244 |
TInt count = zoomValues.Count()-1;
|
|
1245 |
TInt i = 0;
|
|
1246 |
if ( zoomValues.Count() > 0 )
|
|
1247 |
{
|
|
1248 |
extSteps.iMaxPhotoStepW9MP = zoomValues[Min(count,i++)];
|
|
1249 |
extSteps.iMaxPhotoStepW6MP = zoomValues[Min(count,i++)];
|
|
1250 |
extSteps.iMaxPhotoStep12MP = zoomValues[Min(count,i++)]; //KMaxPhoto12MPExtZoomStep;
|
|
1251 |
extSteps.iMaxPhotoStep8MP = zoomValues[Min(count,i++)]; //KMaxPhoto8MPExtZoomStep;
|
|
1252 |
extSteps.iMaxPhotoStep5MP = zoomValues[Min(count,i++)]; //KMaxPhoto5MPExtZoomStep;
|
|
1253 |
extSteps.iMaxPhotoStep3MP = zoomValues[Min(count,i++)]; //KMaxPhoto3MPExtZoomStep;
|
|
1254 |
extSteps.iMaxPhotoStep2MP = zoomValues[Min(count,i++)]; //KMaxPhoto2MPExtZoomStep;
|
|
1255 |
extSteps.iMaxPhotoStep1_3MP = zoomValues[Min(count,i++)]; //KMaxPhoto1_3MPExtZoomStep;
|
|
1256 |
extSteps.iMaxPhotoStep1MP = zoomValues[Min(count,i++)]; //KMaxPhoto1MPExtZoomStep;
|
|
1257 |
extSteps.iMaxPhotoStep0_8MP = zoomValues[Min(count,i++)]; //KMaxPhoto0_8MPExtZoomStep;
|
|
1258 |
extSteps.iMaxPhotoStepSVGA = zoomValues[Min(count,i++)];
|
|
1259 |
extSteps.iMaxPhotoStepVGA = zoomValues[Min(count,i++)]; //KMaxPhotoVGAExtZoomStep;
|
|
1260 |
}
|
|
1261 |
else
|
|
1262 |
{
|
|
1263 |
User::Leave( KErrNotSupported );
|
|
1264 |
}
|
|
1265 |
TCamZoomStepPckg* ptr = static_cast<TCamZoomStepPckg*>( aValue );
|
|
1266 |
*ptr = extSteps;
|
|
1267 |
break;
|
|
1268 |
}
|
|
1269 |
// -----------------------------------------------------
|
|
1270 |
// Zoom appearance
|
|
1271 |
case ECamPsiZoomBarLAF:
|
|
1272 |
{
|
|
1273 |
const TRgb KZoomColourDig = TRgb( 255, 140, 1 );
|
|
1274 |
const TRgb KZoomColourExt = TRgb( 255, 0, 0 );
|
|
1275 |
|
|
1276 |
TCamZoomLAF zoomLAF;
|
|
1277 |
uiConfigManager->SupportedLAFZoomBarL( zoomValues );
|
|
1278 |
|
|
1279 |
if ( zoomValues.Count() > 0 )
|
|
1280 |
{
|
|
1281 |
// Time per zoom tick in milliseconds
|
|
1282 |
zoomLAF.iZoomSpeedDig = zoomValues[0]; //KZoomSpeedDig;
|
|
1283 |
// No of zoom steps per tick
|
|
1284 |
zoomLAF.iZoomStepsDig = zoomValues[2]; //KZoomStepsDig;
|
|
1285 |
|
|
1286 |
// Time per ext zoom tick in milliseconds
|
|
1287 |
zoomLAF.iZoomSpeedExt = zoomValues[1]; //KZoomSpeedExt;
|
|
1288 |
// No of ext zoom steps per tick
|
|
1289 |
zoomLAF.iZoomStepsExt = zoomValues[3]; //KZoomStepsExt;
|
|
1290 |
|
|
1291 |
zoomLAF.iSecondCameraZoomSteps = zoomValues[4]; //K2ndCamZoomStepSize
|
|
1292 |
}
|
|
1293 |
else
|
|
1294 |
{
|
|
1295 |
User::Leave( KErrNotSupported );
|
|
1296 |
}
|
|
1297 |
|
|
1298 |
// Colour of optical zoom in zoom bar
|
|
1299 |
zoomLAF.iZoomColourDig = KZoomColourDig;
|
|
1300 |
// Colour of optical zoom in zoom bar
|
|
1301 |
zoomLAF.iZoomColourExt = KZoomColourExt;
|
|
1302 |
|
|
1303 |
TCamZoomLAFPckg* ptr = static_cast<TCamZoomLAFPckg*>( aValue );
|
|
1304 |
*ptr = zoomLAF;
|
|
1305 |
break;
|
|
1306 |
}
|
|
1307 |
// -----------------------------------------------------
|
|
1308 |
// Exposure compensation values
|
|
1309 |
case ECamPsiEVCompSliderInfo:
|
|
1310 |
{
|
|
1311 |
TCamEvCompRange evComp;
|
|
1312 |
|
|
1313 |
evComp.iMinValue = KEVCompMinVal;
|
|
1314 |
evComp.iMaxValue = KEVCompMaxVal;
|
|
1315 |
evComp.iStepsPerUnit = KEVCompStepsPerUnit;
|
|
1316 |
|
|
1317 |
TCamEVCompPckg* ptr = static_cast<TCamEVCompPckg*>( aValue );
|
|
1318 |
*ptr = evComp;
|
|
1319 |
break;
|
|
1320 |
}
|
|
1321 |
// -----------------------------------------------------
|
|
1322 |
default:
|
|
1323 |
{
|
|
1324 |
return KErrNotSupported;
|
|
1325 |
}
|
|
1326 |
// -----------------------------------------------------
|
|
1327 |
}
|
|
1328 |
CleanupStack::PopAndDestroy( &zoomValues );
|
|
1329 |
return KErrNone;
|
|
1330 |
}
|
|
1331 |
|
|
1332 |
|
|
1333 |
// ---------------------------------------------------------------------------
|
|
1334 |
// CamUtility::ResourceOrientationID
|
|
1335 |
// Returns the resource for the given ID, based on the current Orientation
|
|
1336 |
// ---------------------------------------------------------------------------
|
|
1337 |
//
|
|
1338 |
TInt
|
|
1339 |
CamUtility::ResourceOrientationID( TInt aDefaultResourceID )
|
|
1340 |
{
|
|
1341 |
TCamOrientation orientation;
|
|
1342 |
CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
|
|
1343 |
|
|
1344 |
// Make sure the resource ID is in a valid range
|
|
1345 |
TBool inValidRange = Rng( 0, aDefaultResourceID, R_CAM_LAST_RESOURCE_ID );
|
|
1346 |
__ASSERT_DEBUG( inValidRange, CamPanic(ECamPanicInvalidResource) );
|
|
1347 |
|
|
1348 |
// This should never happen, but we may be being passed the original resource number
|
|
1349 |
if( !inValidRange ) { return aDefaultResourceID; }
|
|
1350 |
|
|
1351 |
// Get the current orientation
|
|
1352 |
// If we don't have the AppUI,
|
|
1353 |
// assume the app is starting up and use the default orientation
|
|
1354 |
if( appUi ) { orientation = appUi->CamOrientation(); }
|
|
1355 |
else { orientation = ECamOrientationDefault; }
|
|
1356 |
|
|
1357 |
__ASSERT_DEBUG( (ECamOrientationTotal > orientation), CamPanic(ECamPanicBadIndex) );
|
|
1358 |
|
|
1359 |
return KRoidLookup[aDefaultResourceID][orientation];
|
|
1360 |
}
|
|
1361 |
|
|
1362 |
|
|
1363 |
// ---------------------------------------------------------------------------
|
|
1364 |
// MapLightSensitivity2IsoValueL
|
|
1365 |
// Maps each general light sensitivity id (TCamLightSensitivityId)
|
|
1366 |
// to a product specific ISO rating.
|
|
1367 |
// ---------------------------------------------------------------------------
|
|
1368 |
//
|
|
1369 |
TInt
|
|
1370 |
CamUtility::MapLightSensitivity2IsoValueL( TCamLightSensitivityId aLightSensitivityId, RArray<TInt>& aSupportedValues )
|
|
1371 |
{
|
|
1372 |
CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
|
|
1373 |
CCameraUiConfigManager* UiConfigManager = appUi->AppController().UiConfigManagerPtr();
|
|
1374 |
|
|
1375 |
aSupportedValues.Sort();
|
|
1376 |
TInt count = aSupportedValues.Count();
|
|
1377 |
if ( count == 0 )
|
|
1378 |
{
|
|
1379 |
return ECamIsoRateAuto;
|
|
1380 |
}
|
|
1381 |
if ( UiConfigManager->IsExtendedLightSensitivitySupported() )
|
|
1382 |
{
|
|
1383 |
// Make sure there is enough supported ISO values for extended light sensitivity
|
|
1384 |
// first value is 0 which means automatic, there should be 5 or more other values
|
|
1385 |
TBool enoughSupported = (count > 5);
|
|
1386 |
if ( !enoughSupported ) {
|
|
1387 |
CamPanic(ECamPanicNotEnoughISOValuesSupported);
|
|
1388 |
}
|
|
1389 |
switch ( aLightSensitivityId )
|
|
1390 |
{
|
|
1391 |
// Supports: 100, 200, 400, 800, 1600, 3200.
|
|
1392 |
case ECamLightSensitivityLow: return aSupportedValues[1];
|
|
1393 |
case ECamLightSensitivityLowMed: return aSupportedValues[2];
|
|
1394 |
case ECamLightSensitivityMed: return aSupportedValues[3];
|
|
1395 |
case ECamLightSensitivityMedHigh: return aSupportedValues[4];
|
|
1396 |
case ECamLightSensitivityHigh: return aSupportedValues[5];
|
|
1397 |
default: return ECamIsoRateAuto;
|
|
1398 |
}
|
|
1399 |
}
|
|
1400 |
else
|
|
1401 |
{
|
|
1402 |
switch ( aLightSensitivityId )
|
|
1403 |
{
|
|
1404 |
case ECamLightSensitivityLow: return aSupportedValues[0];
|
|
1405 |
case ECamLightSensitivityMed: return aSupportedValues[TInt(count/2)];
|
|
1406 |
case ECamLightSensitivityHigh: return aSupportedValues[count-1];
|
|
1407 |
default: return ECamIsoRateAuto;
|
|
1408 |
}
|
|
1409 |
}
|
|
1410 |
}
|
|
1411 |
|
|
1412 |
|
|
1413 |
// ---------------------------------------------------------------------------
|
|
1414 |
// MapSharpnessId2SharpnessValueL
|
|
1415 |
// Maps each general sharpness value (TCamImageSharpnessId)
|
|
1416 |
// to a product specific value.
|
|
1417 |
// ---------------------------------------------------------------------------
|
|
1418 |
//
|
|
1419 |
TInt
|
|
1420 |
CamUtility::MapSharpnessId2SharpnessValueL( TCamImageSharpnessId aSharpnessId )
|
|
1421 |
{
|
|
1422 |
TInt sharpnessValue = 0;
|
|
1423 |
RArray<TInt> supportedValues;
|
|
1424 |
CleanupClosePushL( supportedValues );
|
|
1425 |
|
|
1426 |
CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
|
|
1427 |
if ( appUi && appUi->AppController().UiConfigManagerPtr() )
|
|
1428 |
{
|
|
1429 |
appUi->AppController().UiConfigManagerPtr()->SupportedSharpnessSettingsL(
|
|
1430 |
supportedValues );
|
|
1431 |
}
|
|
1432 |
|
|
1433 |
if ( supportedValues.Count() > 0 )
|
|
1434 |
{
|
|
1435 |
switch( aSharpnessId )
|
|
1436 |
{
|
|
1437 |
case ECamImageSharpnessHard:
|
|
1438 |
sharpnessValue = supportedValues[supportedValues.Count()-1];
|
|
1439 |
break;
|
|
1440 |
case ECamImageSharpnessSoft:
|
|
1441 |
sharpnessValue = supportedValues[0];
|
|
1442 |
break;
|
|
1443 |
case ECamImageSharpnessNorm: // <<fall through>>
|
|
1444 |
default:
|
|
1445 |
sharpnessValue = supportedValues[1]; // normal value = 0
|
|
1446 |
break;
|
|
1447 |
}
|
|
1448 |
}
|
|
1449 |
else
|
|
1450 |
{
|
|
1451 |
User::Leave( KErrNotSupported );
|
|
1452 |
}
|
|
1453 |
CleanupStack::PopAndDestroy( &supportedValues );
|
|
1454 |
|
|
1455 |
return sharpnessValue;
|
|
1456 |
}
|
|
1457 |
|
|
1458 |
|
|
1459 |
// ---------------------------------------------------------------------------
|
|
1460 |
// CamUtility::MapVideoQualityToViewFinderRes
|
|
1461 |
// Return resource id for viewfinder resolution for primary camera
|
|
1462 |
// ---------------------------------------------------------------------------
|
|
1463 |
//
|
|
1464 |
TInt
|
|
1465 |
CamUtility::MapVideoQualityToViewFinderRes( TCamVideoResolution aResolution )
|
|
1466 |
{
|
|
1467 |
PRINT1( _L("Camera => CamUtility::MapVideoQualityToViewFinderRes res (%d)"), aResolution )
|
|
1468 |
switch( aResolution )
|
|
1469 |
{
|
|
1470 |
case ECamVideoResolutionVGA: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER;
|
|
1471 |
case ECamVideoResolutionQVGA: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER;
|
|
1472 |
case ECamVideoResolutionQCIF: return R_CAM_VIEWFINDER_RECT_CIF_CAMCORDER_ADJUSTED;
|
|
1473 |
default: return R_CAM_VIEWFINDER_RECT_QVGA_CAMCORDER;
|
|
1474 |
}
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
#endif // CAMERAAPP_PLUGIN_BUILD
|
|
1478 |
// ---------------------------------------------------------------------------
|
|
1479 |
// CamUtility::GetCommonPsiInt
|
|
1480 |
// Allows retrieval of product specific information (TInt)
|
|
1481 |
// ---------------------------------------------------------------------------
|
|
1482 |
//
|
|
1483 |
TInt CamUtility::GetCommonPsiInt( TCamPsiKey aKey, TInt& aValue )
|
|
1484 |
{
|
|
1485 |
aValue = KErrNotSupported;
|
|
1486 |
|
|
1487 |
switch ( aKey )
|
|
1488 |
{
|
|
1489 |
case ECamPsiOrientation: { aValue = CAknAppUiBase::EAppUiOrientationLandscape; break; }
|
|
1490 |
case ECamPsiPrimaryCameraOrientation: { aValue = CAknAppUiBase::EAppUiOrientationLandscape; break; }
|
|
1491 |
case ECamPsiSecondaryCameraOrientation: { aValue = CAknAppUiBase::EAppUiOrientationPortrait; break; }
|
|
1492 |
case ECamPsiEditingOrientation: { aValue = CAknAppUiBase::EAppUiOrientationPortrait; break; }
|
|
1493 |
|
|
1494 |
default:
|
|
1495 |
{
|
|
1496 |
return KErrNotSupported;
|
|
1497 |
}
|
|
1498 |
}
|
|
1499 |
return KErrNone;
|
|
1500 |
}
|
|
1501 |
|
|
1502 |
|
|
1503 |
// -----------------------------------------------------------------------------
|
|
1504 |
// CamUtility::IsQwertyOpen
|
|
1505 |
// -----------------------------------------------------------------------------
|
|
1506 |
//
|
|
1507 |
TBool CamUtility::IsQwertyOpen()
|
|
1508 |
{
|
|
1509 |
TBool retvalue = EFalse;
|
|
1510 |
TInt status = 0;
|
|
1511 |
TInt err = RProperty::Get( KCRUidAvkon, KAknQwertyInputModeActive, status );
|
|
1512 |
PRINT2(_L("Camera <> CamUtility::IsQwertyOpen err%d status%d"),err, status);
|
|
1513 |
if ( !err && status )
|
|
1514 |
{
|
|
1515 |
retvalue = ETrue;
|
|
1516 |
}
|
|
1517 |
return retvalue;
|
|
1518 |
}
|
|
1519 |
|
|
1520 |
|
|
1521 |
// -----------------------------------------------------------------------------
|
|
1522 |
// CamUtility::ViewfinderLayout
|
|
1523 |
//
|
|
1524 |
// Get resolution from CCamAppController::GetCurrentVideoResolution()
|
|
1525 |
// or CCamAppController::GetCurrentImageResolution().
|
|
1526 |
//
|
|
1527 |
// -----------------------------------------------------------------------------
|
|
1528 |
//
|
|
1529 |
TRect
|
|
1530 |
CamUtility::ViewfinderLayout( TCamCameraMode aMode,
|
|
1531 |
TInt aResolution )
|
|
1532 |
{
|
|
1533 |
PRINT1( _L("Camera => CamUtility::ViewfinderLayout - resolution[%d]"), aResolution );
|
|
1534 |
|
|
1535 |
TAknWindowLineLayout l = IsNhdDevice()
|
|
1536 |
? ViewfinderLayoutTouch(aMode, aResolution)
|
|
1537 |
: ViewfinderLayoutNonTouch(aMode, aResolution);
|
|
1538 |
|
|
1539 |
TRect screenRect;
|
|
1540 |
if ( Layout_Meta_Data::IsLandscapeOrientation() || IsNhdDevice() )
|
|
1541 |
{
|
|
1542 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
|
|
1543 |
}
|
|
1544 |
else
|
|
1545 |
{
|
|
1546 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
|
|
1547 |
}
|
|
1548 |
|
|
1549 |
TAknLayoutRect vfLayoutRect;
|
|
1550 |
vfLayoutRect.LayoutRect( screenRect, l );
|
|
1551 |
TRect vfRect( vfLayoutRect.Rect() );
|
|
1552 |
|
|
1553 |
PRINT4( _L("Camera <= CamUtility::ViewfinderLayout - rect[x:%d y:%d w:%d h:%d]"),
|
|
1554 |
vfRect.iTl.iX, vfRect.iTl.iY, vfRect.Width(), vfRect.Height() );
|
|
1555 |
|
|
1556 |
return vfRect;
|
|
1557 |
}
|
|
1558 |
|
|
1559 |
|
|
1560 |
// -----------------------------------------------------------------------------
|
|
1561 |
// CamUtility::ViewfinderLayoutTouch
|
|
1562 |
//
|
|
1563 |
// -----------------------------------------------------------------------------
|
|
1564 |
//
|
|
1565 |
TAknWindowLineLayout
|
|
1566 |
CamUtility::ViewfinderLayoutTouch( TCamCameraMode aMode,
|
|
1567 |
TInt aResolution )
|
|
1568 |
{
|
|
1569 |
TInt variant = Layout_Meta_Data::IsLandscapeOrientation();
|
|
1570 |
|
|
1571 |
// Default to 4:3 full screen
|
|
1572 |
TAknWindowLineLayout l =
|
|
1573 |
AknLayoutScalable_Apps::cam4_image_uncrop_pane( variant );
|
|
1574 |
|
|
1575 |
// -------------------------------------------------------
|
|
1576 |
// Video mode
|
|
1577 |
if ( ECamControllerVideo == aMode )
|
|
1578 |
{
|
|
1579 |
switch( aResolution )
|
|
1580 |
{
|
|
1581 |
case ECamVideoResolutionQCIF:
|
|
1582 |
case ECamVideoResolutionCIF:
|
|
1583 |
{
|
|
1584 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - QCIF/CIF video resolution") );
|
|
1585 |
l = AknLayoutScalable_Apps::video4_image_uncrop_cif_pane( variant );
|
|
1586 |
break;
|
|
1587 |
}
|
|
1588 |
case ECamVideoResolutionNHD:
|
|
1589 |
case ECamVideoResolutionHD:
|
|
1590 |
{
|
|
1591 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - nHD/HD video resolution") );
|
|
1592 |
l = AknLayoutScalable_Apps::video4_image_uncrop_nhd_pane( variant );
|
|
1593 |
break;
|
|
1594 |
}
|
|
1595 |
default:
|
|
1596 |
{
|
|
1597 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 4:3 video resolution") );
|
|
1598 |
// All other video resolutions are expected to
|
|
1599 |
// have 4:3 aspect ratio
|
|
1600 |
l = AknLayoutScalable_Apps::video4_image_uncrop_vga_pane( variant );
|
|
1601 |
break;
|
|
1602 |
}
|
|
1603 |
}
|
|
1604 |
}
|
|
1605 |
// -------------------------------------------------------
|
|
1606 |
// Image mode
|
|
1607 |
else if ( ECamControllerImage == aMode )
|
|
1608 |
{
|
|
1609 |
switch( aResolution )
|
|
1610 |
{
|
|
1611 |
case ECamPhotoSizeW9MP:
|
|
1612 |
case ECamPhotoSizeW6MP:
|
|
1613 |
{
|
|
1614 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 16:9 still image resolution") );
|
|
1615 |
l = AknLayoutScalable_Apps::video4_image_uncrop_nhd_pane( variant );
|
|
1616 |
break;
|
|
1617 |
}
|
|
1618 |
default:
|
|
1619 |
{
|
|
1620 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutTouch - 4:3 still image resolution") );
|
|
1621 |
l = AknLayoutScalable_Apps::cam4_image_uncrop_pane( variant );
|
|
1622 |
break;
|
|
1623 |
}
|
|
1624 |
}
|
|
1625 |
}
|
|
1626 |
// -------------------------------------------------------
|
|
1627 |
|
|
1628 |
return l;
|
|
1629 |
}
|
|
1630 |
|
|
1631 |
|
|
1632 |
|
|
1633 |
// ---------------------------------------------------------------------------
|
|
1634 |
// CamUtility::ViewfinderLayoutNonTouch
|
|
1635 |
// ---------------------------------------------------------------------------
|
|
1636 |
//
|
|
1637 |
TAknWindowLineLayout
|
|
1638 |
CamUtility::ViewfinderLayoutNonTouch( TCamCameraMode aMode,
|
|
1639 |
TInt aResolution )
|
|
1640 |
{
|
|
1641 |
TInt variant = Layout_Meta_Data::IsLandscapeOrientation() ? 0 : 3;
|
|
1642 |
|
|
1643 |
TAknWindowLineLayout l =
|
|
1644 |
AknLayoutScalable_Apps::cam6_image_uncrop_pane( variant );
|
|
1645 |
|
|
1646 |
// -------------------------------------------------------
|
|
1647 |
// Video mode
|
|
1648 |
if ( ECamControllerVideo == aMode )
|
|
1649 |
{
|
|
1650 |
switch( aResolution )
|
|
1651 |
{
|
|
1652 |
case ECamVideoResolutionQCIF:
|
|
1653 |
case ECamVideoResolutionCIF:
|
|
1654 |
{
|
|
1655 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - QCIF/CIF video resolution") );
|
|
1656 |
l = AknLayoutScalable_Apps::vid6_image_uncrop_cif_pane( variant );
|
|
1657 |
break;
|
|
1658 |
}
|
|
1659 |
case ECamVideoResolutionNHD:
|
|
1660 |
case ECamVideoResolutionHD:
|
|
1661 |
{
|
|
1662 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - nHD/HD video resolution") );
|
|
1663 |
l = AknLayoutScalable_Apps::vid6_image_uncrop_nhd_pane( variant );
|
|
1664 |
break;
|
|
1665 |
}
|
|
1666 |
case ECamVideoResolutionWVGA:
|
|
1667 |
{
|
|
1668 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - WVGA video resolution") );
|
|
1669 |
l = AknLayoutScalable_Apps::vid6_image_uncrop_wvga_pane( variant );
|
|
1670 |
break;
|
|
1671 |
}
|
|
1672 |
default:
|
|
1673 |
{
|
|
1674 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 4:3 video resolution") );
|
|
1675 |
// All other video resolutions are expected to
|
|
1676 |
// have 4:3 aspect ratio
|
|
1677 |
l = AknLayoutScalable_Apps::vid6_image_uncrop_vga_pane( variant );
|
|
1678 |
break;
|
|
1679 |
}
|
|
1680 |
}
|
|
1681 |
}
|
|
1682 |
// -------------------------------------------------------
|
|
1683 |
// Image mode
|
|
1684 |
else
|
|
1685 |
{
|
|
1686 |
switch( aResolution )
|
|
1687 |
{
|
|
1688 |
case ECamPhotoSizeW9MP:
|
|
1689 |
case ECamPhotoSizeW6MP:
|
|
1690 |
{
|
|
1691 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 16:9 still image resolution") );
|
|
1692 |
l = AknLayoutScalable_Apps::vid6_image_uncrop_nhd_pane( variant );
|
|
1693 |
}
|
|
1694 |
default:
|
|
1695 |
{
|
|
1696 |
PRINT( _L("Camera <> CamUtility::ViewfinderLayoutNonTouch - 4:3 still image resolution") );
|
|
1697 |
l = AknLayoutScalable_Apps::cam6_image_uncrop_pane( variant );
|
|
1698 |
break;
|
|
1699 |
}
|
|
1700 |
}
|
|
1701 |
}
|
|
1702 |
// -------------------------------------------------------
|
|
1703 |
|
|
1704 |
return l;
|
|
1705 |
}
|
|
1706 |
|
|
1707 |
|
|
1708 |
// End of File
|
|
1709 |
|