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 |
|
20 #ifndef CAMUTILITY_H |
|
21 #define CAMUTILITY_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <CAknMemorySelectionSettingPage.h> |
|
26 |
|
27 #include <bldvariant.hrh> |
|
28 #include "CamPSI.h" // Product Specific Information |
|
29 #include "CamSettings.hrh" // for TCamMediaStorage |
|
30 #include "CamSettingsInternal.hrh" |
|
31 #include "camlogging.h" |
|
32 #include "camconfigurationtypes.h" |
|
33 |
|
34 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
35 #include "CamResourceIDs.h" |
|
36 #endif //CAMERAAPP_PLUGIN_BUILD |
|
37 |
|
38 #include <driveinfo.h> |
|
39 |
|
40 // CONSTANTS |
|
41 /* estimated average image sizes */ |
|
42 const TInt KCamImageSize3MP = 750000; |
|
43 const TInt KCamImageSize2MP = 475000; |
|
44 const TInt KCamImageSize1_3MP = 325000; |
|
45 const TInt KCamImageSize1MP = 90000; |
|
46 const TInt KCamImageSizeVGA = 56500; |
|
47 |
|
48 const TInt KCamLocationTrailStopped = 0; |
|
49 const TInt KCamLocationTrailNoValidData = 1; |
|
50 const TInt KCamLocationTrailSearchingDevice = 2; |
|
51 const TInt KCamLocationTrailGPSDataAvail = 3; |
|
52 |
|
53 // A multiple of the image size is kept as a buffer to ensure that a |
|
54 // complex last image can be captured |
|
55 const TInt KCamImageDataBufferMultiplier = 1; |
|
56 |
|
57 // Name of the server that takes foreground when charger is inserted |
|
58 _LIT( KAknCapServer, "akncapserver" ); |
|
59 // Location data notification windows use this server. |
|
60 _LIT( KAknNotifyServer, "aknnfysrv" ); |
|
61 |
|
62 // Phonebook server |
|
63 _LIT( KPbkServer, "Pbk2ServerApp" ); |
|
64 |
|
65 // DATA TYPES |
|
66 /** |
|
67 * Memory card status, as returned by MemoryCardStatus() |
|
68 */ |
|
69 enum TCamMemoryCardStatus |
|
70 { |
|
71 ECamMemoryCardNotInserted, |
|
72 ECamMemoryCardLocked, |
|
73 ECamMemoryCardInserted |
|
74 }; |
|
75 |
|
76 #ifndef CAMERAAPP_PLUGIN_BUILD |
|
77 #define ROID(resource_id) (CamUtility::ResourceOrientationID(resource_id)) |
|
78 |
|
79 // Capture tone resources |
|
80 _LIT( KCamCaptureTone1, "z:\\system\\sounds\\digital\\cameraappCapture1.wav" ); |
|
81 _LIT( KCamCaptureTone2, "z:\\system\\sounds\\digital\\cameraappCapture2.wav" ); |
|
82 _LIT( KCamCaptureTone3, "z:\\system\\sounds\\digital\\cameraappCapture3.wav" ); |
|
83 _LIT( KCamCaptureTone4, "z:\\system\\sounds\\digital\\cameraappCapture4.wav" ); |
|
84 _LIT( KCamBurstCaptureTone1, "z:\\system\\sounds\\digital\\cameraappCaptureShort1.wav" ); |
|
85 _LIT( KCamBurstCaptureTone2, "z:\\system\\sounds\\digital\\cameraappCaptureShort2.wav" ); |
|
86 _LIT( KCamBurstCaptureTone3, "z:\\system\\sounds\\digital\\cameraappCaptureShort3.wav" ); |
|
87 _LIT( KCamBurstCaptureTone4, "z:\\system\\sounds\\digital\\cameraappCaptureShort4.wav" ); |
|
88 _LIT( KCamVideoStartTone, "z:\\system\\sounds\\digital\\cameraappStart.wav" ); |
|
89 _LIT( KCamVideoPauseTone, "z:\\system\\sounds\\digital\\cameraappStop.wav" ); |
|
90 _LIT( KCamVideoStopTone, "z:\\system\\sounds\\digital\\cameraappStop.wav" ); |
|
91 _LIT( KCamAutoFocusComplete, "z:\\system\\sounds\\digital\\cameraappFocusSucc.wav" ); |
|
92 _LIT( KCamSelfTimerTone, "z:\\system\\sounds\\digital\\cameraappSelfTimer.wav" ); |
|
93 |
|
94 #endif //CAMERAAPP_PLUGIN_BUILD |
|
95 |
|
96 // CLASS DECLARATION |
|
97 |
|
98 /** |
|
99 * Application wide utility functions |
|
100 * |
|
101 * @since 2.8 |
|
102 */ |
|
103 |
|
104 class CamUtility |
|
105 { |
|
106 public : // New functions |
|
107 |
|
108 /** |
|
109 * Get free space in selected memory |
|
110 * @since 2.8 |
|
111 * @param aMemory memory card or internal memory |
|
112 * @param aCriticalLevel The critical threshold on the specified drive |
|
113 * @return free space in selected memory (in bytes) |
|
114 */ |
|
115 static TInt64 MemoryFree( |
|
116 DriveInfo::TDefaultDrives aMemory, |
|
117 TInt aCriticalLevel = 0 ); |
|
118 |
|
119 /** |
|
120 * Returns the memory card status. |
|
121 * @since 2.8 |
|
122 * @return the status. |
|
123 */ |
|
124 static TCamMemoryCardStatus MemoryCardStatus(); |
|
125 |
|
126 /** |
|
127 * Get drive number for memory card. |
|
128 * @since 2.8 |
|
129 * @return drive number for memory card |
|
130 */ |
|
131 static TInt MemoryCardDrive(); |
|
132 |
|
133 /** |
|
134 * Get drive number for phone memory. |
|
135 * @since 2.8 |
|
136 * @return drive number for phone memory |
|
137 */ |
|
138 static TInt PhoneMemoryDrive(); |
|
139 |
|
140 |
|
141 /** |
|
142 * Get drive number for mass storage memory. |
|
143 * @since 3.2 |
|
144 * @return drive number for mass storage memory |
|
145 */ |
|
146 static TInt MassMemoryDrive(); |
|
147 |
|
148 /** |
|
149 * Get drive type for a given drive number. |
|
150 * @since 3.2 |
|
151 * @return DriveInfo::TDefaultDrives type for the drive number |
|
152 */ |
|
153 static TInt GetDriveTypeFromDriveNumber( TInt aDrive ); |
|
154 |
|
155 /** |
|
156 * Map camera storage location to memory selection dialog storage location |
|
157 * @param aStorage The camera storage location to map |
|
158 * @since 3.0 |
|
159 * @return the memory selection dialog's mapped memory storage location value |
|
160 */ |
|
161 static TInt MapToSettingsListMemory( TInt aStorage ); |
|
162 |
|
163 /** |
|
164 * Map memory selection dialog storage location to camera storage location |
|
165 * @param aStorage The settings list memory location to map |
|
166 * @since 3.0 |
|
167 * @return the camera storage location mapped from the memory selection dialog's location value |
|
168 */ |
|
169 static TInt MapFromSettingsListMemory( TInt aStorage ); |
|
170 |
|
171 /** |
|
172 * Suggest a new unique filename |
|
173 * @since 2.8 |
|
174 * @param aFilePath (in/out) drive and path for file name |
|
175 * (must include trailing '\') |
|
176 * On return contains the full path and |
|
177 * generated file name with extension |
|
178 * @param aFilename (in/out) filename (without path or extension) |
|
179 * @param aSuggestedNumeral number initially appended to the name to ensure |
|
180 * uniqueness, the actual number used may be higher |
|
181 * @param aExt file extension (".jpg" or ".3gp") |
|
182 */ |
|
183 static void GetUniqueNameL( TDes& aFilePath, |
|
184 TDes& aFilename, |
|
185 TInt aSuggestedNumeral, |
|
186 const TDesC& aExt ); |
|
187 |
|
188 /** |
|
189 * Generate a image file name based on base name and counter. |
|
190 * @since 2.8 |
|
191 * @param aCounter image counter [1...] |
|
192 * @param aBaseName name base |
|
193 * @param aFilename descriptor to hold the generated file name. |
|
194 * Does not include path or extension. Example: |
|
195 * "Image(001)" |
|
196 */ |
|
197 static void FormatFileName( TUint aCounter, |
|
198 const TDesC& aBaseName, |
|
199 TDes& aFilename ); |
|
200 |
|
201 /** |
|
202 * Checks if given filename contains illegal characters or |
|
203 * is otherwise illegal. |
|
204 * @since 2.8 |
|
205 * @param aFilename descriptor that holds file name to check. |
|
206 */ |
|
207 static TBool CheckFileNameValidityL( const TDesC& aFilename ); |
|
208 |
|
209 /** |
|
210 * Generate a file name based on date and counter. |
|
211 * @since 2.8 |
|
212 * @param aFilename descriptor to hold the generated file name. |
|
213 * Does not include path or extension. Example: |
|
214 * "240305(001)" |
|
215 */ |
|
216 static void FormatDateFileNameL( TDes& aFilename ); |
|
217 |
|
218 /** |
|
219 * Format current date into given descriptor in a format |
|
220 * suitable for file names. |
|
221 * @since 2.8 |
|
222 * @param aBuffer the buffer to receive the formatted date. |
|
223 */ |
|
224 static void GetCurrentDateForNameBaseL( TDes& aBuffer ); |
|
225 |
|
226 |
|
227 /** |
|
228 * Return the path and filename of the application MBM file |
|
229 * @since 2.8 |
|
230 * @param aResName Populated with path and filename of MBM file |
|
231 */ |
|
232 static void ResourceFileName( TDes& aResName ); |
|
233 |
|
234 /** |
|
235 * Return Product Specific Information in the form of a TInt |
|
236 * @since 2.8 |
|
237 * @param aKey The enumeration key identifying the data required |
|
238 * @param aValue A reference to TInt that will hold the data |
|
239 * @return KErrNone if successful, KErrNotSupported if no valid data. |
|
240 */ |
|
241 static TInt GetPsiInt( TCamPsiKey aKey, TInt& aValue ); |
|
242 |
|
243 /** |
|
244 * Return Product Specific Information in the form of a TInt array |
|
245 * @since 3.0 |
|
246 * @param aKey The enumeration key identifying the data required |
|
247 * @param aValue A reference to a TInt array that will hold the data |
|
248 * @return KErrNone if successful, KErrNotSupported if no valid data. |
|
249 */ |
|
250 static TInt GetPsiIntArrayL( TCamPsiKey aKey, RArray<TInt>& aValue ); |
|
251 |
|
252 /** |
|
253 * Return Product Specific Information in the form of a TInt |
|
254 * @since 2.8 |
|
255 * @param aKey The enumeration key identifying the data required |
|
256 * @param aValue A reference to TInt that will hold the data |
|
257 * @return KErrNone if successful, KErrNotSupported if no valid data. |
|
258 */ |
|
259 static TInt GetCommonPsiInt( TCamPsiKey aKey, TInt& aValue ); |
|
260 |
|
261 /** |
|
262 * Return Product Specific Information in the form of a TAny* |
|
263 * @since 2.8 |
|
264 * @param aKey The enumeration key identifying the data required |
|
265 * @param aValue A pointer to where the data should be copied to. |
|
266 * note, data is Mem::Copied, so sufficient space must be |
|
267 * available in the buffer passed in to "aValue" |
|
268 * @return KErrNone if successful, KErrNotSupported if no valid data. |
|
269 */ |
|
270 static TInt GetPsiAnyL( TCamPsiKey aKey, TAny* aValue ); |
|
271 |
|
272 /** |
|
273 * Return maximum size for an MMS message |
|
274 * @since 2.8 |
|
275 * @return The maximum size |
|
276 */ |
|
277 static TInt MaxMmsSizeInBytesL(); |
|
278 |
|
279 /** |
|
280 * Compares two strings. |
|
281 * @since 2.8 |
|
282 * @param aFirst The first string. |
|
283 * @param aSecond The second string |
|
284 * @return ETrue if the strings are equivalent. |
|
285 */ |
|
286 static TBool CompareIgnoreCase( const TDesC& aFirst, |
|
287 const TDesC& aSecond ); |
|
288 |
|
289 /** |
|
290 * Deletes a video clip. |
|
291 * @since 2.8 |
|
292 * @param aFilename The filename of the video clip |
|
293 */ |
|
294 static void DeleteVideoL( const TDesC& aFilename ); |
|
295 |
|
296 /** |
|
297 * Deletes an image. |
|
298 * @since 2.8 |
|
299 * @param aFilename The filename of the image |
|
300 */ |
|
301 static void DeleteStillImageL( const TDesC& aFilename ); |
|
302 |
|
303 /** |
|
304 * Returns the thumbnail path for an image. |
|
305 * @since 2.8 |
|
306 * @param aImagePath The path of the image |
|
307 * @param aThumbnailPath The path of the thumbnail image |
|
308 */ |
|
309 static void GetThumbnailPath( const TDesC& aImagePath, |
|
310 TDes& aThumbnailPath ); |
|
311 |
|
312 /** |
|
313 * Renames a still image. |
|
314 * @since 2.8 |
|
315 * @param aOldPath The old path of the image |
|
316 * @param aNewName The new name of the image |
|
317 * @param aNewPath Receives the new path of the image. |
|
318 */ |
|
319 static void RenameStillImageL( const TDesC& aOldPath, |
|
320 const TDesC& aNewName, |
|
321 TDes& aNewPath ); |
|
322 |
|
323 /** |
|
324 * Takes a window group ID and a group name. Checks to see if the |
|
325 * window group referred to by the ID has a name containing the |
|
326 * window group name string. |
|
327 * @since 3.0 |
|
328 * @param aWindowId ID of the window group |
|
329 * @param aWindowGroupName Name to check for |
|
330 * @return ETrue if ID matches name |
|
331 */ |
|
332 static TBool IdMatchesName( TInt aWindowId, const TDesC& aWindowGroupName ); |
|
333 |
|
334 /** |
|
335 * Returns the correct resource ID for the current orientation |
|
336 * @since 3.0 |
|
337 * @param aDefaultResourceID The resource ID for the default orientation |
|
338 * @return The new resource ID |
|
339 */ |
|
340 |
|
341 static TInt ResourceOrientationID( TInt aDefaultResourceID ); |
|
342 |
|
343 /** |
|
344 * Map light sensitivity id to ISO rating value. |
|
345 * |
|
346 */ |
|
347 static TInt MapLightSensitivity2IsoValueL( TCamLightSensitivityId aLightSensitivityId, RArray<TInt>& aSupportedValues ); |
|
348 |
|
349 /** |
|
350 * Map UI sharpness setting id to Camera sharpness setting value. |
|
351 * |
|
352 */ |
|
353 static TInt MapSharpnessId2SharpnessValueL( TCamImageSharpnessId aSharpnessId ); |
|
354 |
|
355 /** |
|
356 * Obtain resource id for specific video reoslution |
|
357 * (for primary camera) |
|
358 * @since 3.0 |
|
359 * @param aResolution video reoslution |
|
360 * @return resource id |
|
361 */ |
|
362 static TInt MapVideoQualityToViewFinderRes( TCamVideoResolution aResolution ); |
|
363 |
|
364 /** |
|
365 * Determines if the battery power is good |
|
366 * @since 3.0 |
|
367 * @return ETrue if the battery is OK, and EFalse if it is |
|
368 * low or almost empty |
|
369 */ |
|
370 static TBool IsBatteryPowerOK(); |
|
371 |
|
372 /** |
|
373 * Determines if the battery power is empty |
|
374 * @since 3.0 |
|
375 * @return ETrue if the battery is Empty |
|
376 */ |
|
377 static TBool IsBatteryPowerEmpty(); |
|
378 |
|
379 /** |
|
380 * Determines if the battery is being charged |
|
381 * @since 3.0 |
|
382 * @return ETrue if the battery is charging |
|
383 */ |
|
384 static TBool IsBatteryCharging(); |
|
385 |
|
386 /** |
|
387 * Determines if LocationTrail is started |
|
388 * @return ETrue if LocationTrail is started |
|
389 */ |
|
390 static TBool IsLocationAware(); |
|
391 |
|
392 /** |
|
393 * Replaces original bitmap by bitmap with alpha channel. |
|
394 * @since S60 5.0 |
|
395 * @param aBmp, bitmap |
|
396 * @param aMask, mask |
|
397 * @param aColor, Color used instead of white. |
|
398 */ |
|
399 static void SetAlphaL( CFbsBitmap*& aBmp, CFbsBitmap*& aMask, |
|
400 TRgb aColor = KRgbWhite ); |
|
401 |
|
402 /** |
|
403 * Determines if USB is active |
|
404 * @return ETrue if USB is active |
|
405 */ |
|
406 static TBool IsUsbActive(); |
|
407 |
|
408 /** |
|
409 * Determines if the device has a NHD display. |
|
410 * This method is meant to be used with the layouts only |
|
411 * @return ETrue if NHD (640 x 360) display |
|
412 */ |
|
413 static TBool IsNhdDevice(); |
|
414 |
|
415 /** |
|
416 * Determines device qwerty-mode state. |
|
417 * This method is meant to be used with secondary camera. |
|
418 * @return ETrue if qwerty keyboard is open |
|
419 */ |
|
420 static TBool IsQwertyOpen(); |
|
421 |
|
422 /** |
|
423 * Get layout rectangle for given resolution in given mode. |
|
424 * @param aMode ECamControllerVideo or ECamControllerImage. |
|
425 * @param aResolution Resolution enumeration from |
|
426 * CCamAppController::GetCurrentVideoResolution or |
|
427 * CCamAppController::GetCurrentImageResolution depending |
|
428 * on the mode. |
|
429 * |
|
430 */ |
|
431 static TRect ViewfinderLayout( TCamCameraMode aMode, |
|
432 TInt aResolution ); |
|
433 |
|
434 private: |
|
435 |
|
436 /** |
|
437 * Helper method for ViewfinderLayout. |
|
438 */ |
|
439 static TAknWindowLineLayout ViewfinderLayoutTouch( TCamCameraMode aMode, |
|
440 TInt aResolution ); |
|
441 |
|
442 /** |
|
443 * Helper method for ViewfinderLayout. |
|
444 */ |
|
445 static TAknWindowLineLayout ViewfinderLayoutNonTouch( TCamCameraMode aMode, |
|
446 TInt aResolution ); |
|
447 |
|
448 |
|
449 }; |
|
450 |
|
451 #endif // CAMUTILITY_H |
|
452 |
|
453 // End of File |
|