|
1 /* |
|
2 * Copyright (c) 2002-2006 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: |
|
15 * This class contains a collection of small static utility functions |
|
16 * needed all around the application. The class has no prefix letter |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <eikapp.h> |
|
25 #include <eikenv.h> |
|
26 #include <bautils.h> |
|
27 #include <centralrepository.h> |
|
28 #include <coemain.h> |
|
29 #include <f32file.h> |
|
30 #include <StringLoader.h> |
|
31 #include <AknGlobalNote.h> |
|
32 #include <aknnotewrappers.h> |
|
33 #include <e32property.h> |
|
34 #include <ctsydomainpskeys.h> |
|
35 #include <pathinfo.h> |
|
36 #include <featmgr.h> |
|
37 #include <avkon.rsg> |
|
38 #include <e32math.h> |
|
39 |
|
40 #include <voicerecorder.rsg> |
|
41 #include <VoiceRecorderUID.h> |
|
42 |
|
43 #ifdef RD_MULTIPLE_DRIVE |
|
44 #include <driveinfo.h> |
|
45 #include <pathinfo.h> |
|
46 #endif |
|
47 |
|
48 #include "VoiceRecorderInternalCRKeys.h" |
|
49 #include "VRUtils.h" |
|
50 #include "VRConsts.h" |
|
51 #include <bldvariant.hrh> |
|
52 |
|
53 // CONSTANTS |
|
54 _LIT( KVRAMRFileNameExtension, ".amr" ); |
|
55 _LIT( KVRWAVFileNameExtension, ".wav" ); |
|
56 |
|
57 // added for AAC |
|
58 #ifdef __AAC_ENCODER_PLUGIN |
|
59 _LIT( KVRAAC_LCFileNameExtension,".mp4" ); |
|
60 #endif |
|
61 |
|
62 _LIT( KVROneToNineClipCountFormat, "%02d" ); // used with clip numbers 1..9 |
|
63 _LIT( KVRDefaultClipCountFormat, "%d" ); // used with clip numbers 10-> |
|
64 |
|
65 |
|
66 // ================= MEMBER FUNCTIONS ======================================== |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // VRUtils::MemoStoreDirectoryL |
|
70 // Checks what is the current storage place and returns the corresponding path |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C void VRUtils::MemoStoreDirectoryL( TDes &aPath ) |
|
74 { |
|
75 |
|
76 TFileName phoneMemoryPath; |
|
77 |
|
78 #ifndef RD_MULTIPLE_DRIVE |
|
79 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
80 { |
|
81 |
|
82 TVRMemoStore memoStore = MemoStoreL(); |
|
83 if ( memoStore == EMemoStorePhoneMemory ) |
|
84 { |
|
85 phoneMemoryPath = PathInfo::PhoneMemoryRootPath(); |
|
86 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
87 aPath.Copy( phoneMemoryPath ); |
|
88 return; |
|
89 } |
|
90 else |
|
91 { |
|
92 // MMC is the selected memo store. Check if it's available. |
|
93 TVRDriveInfo mmcInfo; |
|
94 GetMMCInfo( mmcInfo ); |
|
95 if ( mmcInfo.iDrivePresent && !mmcInfo.iDriveLocked && |
|
96 !mmcInfo.iDriveCorrupted && !mmcInfo.iDriveReadOnly ) |
|
97 { |
|
98 // MMC usage is OK. |
|
99 TFileName mmcPath = PathInfo::MemoryCardRootPath(); |
|
100 mmcPath.Append( PathInfo::DigitalSoundsPath() ); |
|
101 aPath.Copy( mmcPath ); |
|
102 return; |
|
103 } |
|
104 else |
|
105 { |
|
106 // MMC is unavailable => return phone memory path |
|
107 phoneMemoryPath = PathInfo::PhoneMemoryRootPath(); |
|
108 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
109 aPath.Copy( phoneMemoryPath ); |
|
110 return; |
|
111 } |
|
112 |
|
113 } |
|
114 |
|
115 } |
|
116 else |
|
117 { |
|
118 phoneMemoryPath = PathInfo::PhoneMemoryRootPath(); |
|
119 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
120 aPath.Copy( phoneMemoryPath ); |
|
121 return; |
|
122 } |
|
123 |
|
124 // using multiple drive |
|
125 #else |
|
126 TInt memoDrive = MemoDriveL(); |
|
127 TInt defaultDrive(0); |
|
128 User::LeaveIfError( defaultDrive = DefaultMemoDriveL()); |
|
129 //default drive |
|
130 if ( memoDrive == defaultDrive ) |
|
131 { |
|
132 User::LeaveIfError( PathInfo::GetRootPath( phoneMemoryPath, memoDrive ) ); |
|
133 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
134 aPath.Copy( phoneMemoryPath ); |
|
135 return; |
|
136 } |
|
137 // other drives |
|
138 else |
|
139 { |
|
140 TUint status( 0 ); |
|
141 VRUtils::GetDriveInfo(memoDrive, status); |
|
142 // check if drive status is ok |
|
143 if ( (status & DriveInfo::EDrivePresent) && !(status & DriveInfo::EDriveLocked) && |
|
144 !( status & DriveInfo::EDriveCorrupt ) && !( status & DriveInfo::EDriveReadOnly ) ) |
|
145 { |
|
146 // Drive usage is OK. |
|
147 User::LeaveIfError( PathInfo::GetRootPath( phoneMemoryPath, memoDrive ) ); |
|
148 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
149 aPath.Copy( phoneMemoryPath ); |
|
150 return; |
|
151 } |
|
152 |
|
153 // if not ok, save to default device drive |
|
154 else |
|
155 { |
|
156 memoDrive = defaultDrive; |
|
157 User::LeaveIfError( PathInfo::GetRootPath( phoneMemoryPath, memoDrive ) ); |
|
158 phoneMemoryPath.Append( PathInfo::DigitalSoundsPath() ); |
|
159 aPath.Copy( phoneMemoryPath ); |
|
160 return; |
|
161 } |
|
162 |
|
163 } |
|
164 #endif |
|
165 } |
|
166 |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // VRUtils::SetMemoStoreL |
|
170 // |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C void VRUtils::SetMemoStoreL( TVRMemoStore aMemory ) |
|
174 { |
|
175 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
176 { |
|
177 SetSettingValueL( KVRMemoStore, aMemory ); |
|
178 } |
|
179 else |
|
180 { |
|
181 __ASSERT_DEBUG( ETrue, User::Panic( KVRPanic, EPanicInvalidSetting ) ); |
|
182 } |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // VRUtils::MemoStoreL |
|
188 // |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C TVRMemoStore VRUtils::MemoStoreL() |
|
192 { |
|
193 // Phone memory is the default |
|
194 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
195 { |
|
196 TInt ret = SettingValueL( KVRMemoStore, |
|
197 EMemoStorePhoneMemory ); |
|
198 return static_cast< TVRMemoStore >( ret ); |
|
199 } |
|
200 else |
|
201 { |
|
202 return EMemoStorePhoneMemory; |
|
203 } |
|
204 } |
|
205 |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // VRUtils::DefaultSpeakerL |
|
209 // |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C TVRSpeaker VRUtils::DefaultSpeakerL() |
|
213 { |
|
214 if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) && |
|
215 FeatureManager::FeatureSupported( |
|
216 KFeatureIdApplicationControllableAudioRouting ) ) |
|
217 { |
|
218 return ( TVRSpeaker ) SettingValueL( KVRDefaultSpeaker, ESpeakerIhf ); |
|
219 } |
|
220 else |
|
221 { |
|
222 return ESpeakerIhf; |
|
223 } |
|
224 } |
|
225 |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // VRUtils::SetDefaultSpeakerL |
|
229 // |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 EXPORT_C void VRUtils::SetDefaultSpeakerL( const TVRSpeaker aSpeaker ) |
|
233 { |
|
234 if ( FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ) && |
|
235 FeatureManager::FeatureSupported( |
|
236 KFeatureIdApplicationControllableAudioRouting ) ) |
|
237 { |
|
238 SetSettingValueL( KVRDefaultSpeaker, aSpeaker ); |
|
239 } |
|
240 else |
|
241 { |
|
242 __ASSERT_DEBUG( ETrue, User::Panic( KVRPanic, EPanicInvalidSetting ) ); |
|
243 } |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // VRUtils::QualityL |
|
249 // |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C TVRQuality VRUtils::QualityL() |
|
253 { |
|
254 if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
255 { |
|
256 return ( TVRQuality ) SettingValueL( KVRQuality, |
|
257 EQualityMMSOptimized ); |
|
258 } |
|
259 else |
|
260 { |
|
261 return EQualityMMSOptimized; |
|
262 } |
|
263 } |
|
264 |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // VRUtils::SetQualityL |
|
268 // |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 EXPORT_C void VRUtils::SetQualityL( const TVRQuality aQuality ) |
|
272 { |
|
273 if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
274 { |
|
275 SetSettingValueL( KVRQuality, aQuality ); |
|
276 } |
|
277 else |
|
278 { |
|
279 __ASSERT_DEBUG( ETrue, User::Panic( KVRPanic, EPanicInvalidSetting ) ); |
|
280 } |
|
281 } |
|
282 |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // VRUtils::SetDefaultVolumeL |
|
286 // |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 EXPORT_C void VRUtils::SetDefaultVolumeL( const TVRSpeaker aSpeaker, |
|
290 const TInt aVolume ) |
|
291 { |
|
292 switch ( aSpeaker ) |
|
293 { |
|
294 case ESpeakerEarPiece: |
|
295 { |
|
296 SetSettingValueL( KVREarPieceVolume, aVolume ); |
|
297 break; |
|
298 } |
|
299 case ESpeakerIhf: |
|
300 { |
|
301 SetSettingValueL( KVRIHFVolume, aVolume ); |
|
302 break; |
|
303 } |
|
304 default: |
|
305 { |
|
306 break; |
|
307 } |
|
308 } |
|
309 return; |
|
310 } |
|
311 |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // VRUtils::DefaultVolumeL |
|
315 // |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 EXPORT_C TInt VRUtils::DefaultVolumeL( const TVRSpeaker aSpeaker ) |
|
319 { |
|
320 TInt volume( KVRDefaultVolume ); |
|
321 switch ( aSpeaker ) |
|
322 { |
|
323 case ESpeakerEarPiece: |
|
324 { |
|
325 volume = SettingValueL( KVREarPieceVolume, KVRDefaultVolume ); |
|
326 break; |
|
327 } |
|
328 case ESpeakerIhf: |
|
329 { |
|
330 volume = SettingValueL( KVRIHFVolume, KVRDefaultVolume ); |
|
331 break; |
|
332 } |
|
333 default: |
|
334 { |
|
335 break; |
|
336 } |
|
337 } |
|
338 return volume ? volume : KVRDefaultVolume; |
|
339 } |
|
340 |
|
341 |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // VRUtils::SetSettingValueL, |
|
345 // save the data to central repository |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 void VRUtils::SetSettingValueL( const TUint32 aKey, const TInt aValue ) |
|
349 { |
|
350 CRepository* repository = CRepository::NewL( KCRUidVoiceRecorder ); |
|
351 CleanupStack::PushL( repository ); |
|
352 User::LeaveIfError( repository->Set( aKey, aValue ) ); |
|
353 CleanupStack::PopAndDestroy( repository ); |
|
354 } |
|
355 |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // VRUtils::SettingValueL |
|
359 // |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 TInt VRUtils::SettingValueL( const TUint32 aKey, const TInt aDefaultValue ) |
|
363 { |
|
364 TInt data; |
|
365 |
|
366 CRepository* repository = CRepository::NewL( KCRUidVoiceRecorder ); |
|
367 CleanupStack::PushL( repository ); |
|
368 |
|
369 // Get the value, create the key if no value was found |
|
370 if ( repository->Get( aKey, data ) != KErrNone ) |
|
371 { |
|
372 User::LeaveIfError( repository->Create( aKey, aDefaultValue ) ); |
|
373 data = aDefaultValue; |
|
374 } |
|
375 |
|
376 CleanupStack::PopAndDestroy( repository ); |
|
377 |
|
378 return data; |
|
379 } |
|
380 |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // VRUtils::GetMMCInfo |
|
384 // |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C void VRUtils::GetMMCInfo( TVRDriveInfo& aMMCInfo ) |
|
388 { |
|
389 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
390 { |
|
391 TDriveInfo driveInfo; |
|
392 TVolumeInfo volumeInfo; |
|
393 RFs& fss = CCoeEnv::Static()->FsSession() ; |
|
394 |
|
395 TInt err( fss.Drive( driveInfo, EDriveE ) ); |
|
396 |
|
397 if ( driveInfo.iType != EMediaNotPresent ) |
|
398 { |
|
399 aMMCInfo.iDrivePresent = ETrue; |
|
400 if ( fss.Volume( volumeInfo, EDriveE ) == KErrCorrupt ) |
|
401 { |
|
402 aMMCInfo.iDriveCorrupted = ETrue; |
|
403 } |
|
404 else |
|
405 { |
|
406 aMMCInfo.iDriveCorrupted = EFalse; |
|
407 } |
|
408 } |
|
409 else |
|
410 { |
|
411 aMMCInfo.iDriveCorrupted = EFalse; |
|
412 aMMCInfo.iDrivePresent = EFalse; |
|
413 } |
|
414 |
|
415 if ( driveInfo.iMediaAtt & KMediaAttLocked || err == KErrLocked ) |
|
416 { |
|
417 aMMCInfo.iDriveLocked = ETrue; |
|
418 } |
|
419 else |
|
420 { |
|
421 aMMCInfo.iDriveLocked = EFalse; |
|
422 } |
|
423 |
|
424 if ( driveInfo.iMediaAtt & KMediaAttWriteProtected ) |
|
425 { |
|
426 aMMCInfo.iDriveReadOnly = ETrue; |
|
427 } |
|
428 else |
|
429 { |
|
430 aMMCInfo.iDriveReadOnly = EFalse; |
|
431 } |
|
432 if ( volumeInfo.iFree ==0 ) |
|
433 { |
|
434 aMMCInfo.iDriveFull = ETrue; |
|
435 } |
|
436 else |
|
437 { |
|
438 aMMCInfo.iDriveFull = EFalse; |
|
439 } |
|
440 |
|
441 |
|
442 } |
|
443 } |
|
444 |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // VRUtils::ShowMemoryFullConfirmationQuery |
|
448 // |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 EXPORT_C void VRUtils::ShowMemoryFullConfirmationQuery( TBool aMmc ) |
|
452 { |
|
453 // Error ignored. If the note fails, there's nothing to do. |
|
454 TRAP_IGNORE( ShowMemoryFullConfirmationQueryL( aMmc ) ); |
|
455 } |
|
456 |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // VRUtils::UnsupportedCallTypeOngoing |
|
460 // |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 EXPORT_C TBool VRUtils::UnsupportedCallTypeOngoing( TBool aShowNote ) |
|
464 { |
|
465 TBool unsupported( EFalse ); |
|
466 TInt value( 0 ); |
|
467 |
|
468 TInt err( 0 ); |
|
469 RProperty property; |
|
470 err = property.Attach( KPSUidCtsyCallInformation, KCTsyCallState ); |
|
471 if ( err ) |
|
472 { |
|
473 return EFalse; |
|
474 } |
|
475 |
|
476 property.Get( value ); |
|
477 |
|
478 switch ( value ) |
|
479 { |
|
480 case EPSCTsyCallStateUninitialized: |
|
481 case EPSCTsyCallStateNone: |
|
482 { // No any kind of call in progress |
|
483 return EFalse; |
|
484 } |
|
485 default: // Call in progress, check if it is videocall |
|
486 { |
|
487 err = property.Attach( KPSUidCtsyCallInformation, KCTsyCallType); |
|
488 if ( err ) |
|
489 { |
|
490 return EFalse; |
|
491 } |
|
492 value = 0; |
|
493 property.Get( value ); |
|
494 break; |
|
495 } |
|
496 } |
|
497 |
|
498 switch( value ) |
|
499 { |
|
500 // Video call ongoing |
|
501 case EPSCTsyCallTypeH324Multimedia: |
|
502 { |
|
503 unsupported = ETrue; |
|
504 |
|
505 if ( aShowNote ) |
|
506 { |
|
507 // If the note fails, it's no big deal |
|
508 TRAP_IGNORE( ShowUnsupportedCallTypeNoteL( |
|
509 R_VR_VIDEO_CALL_INFONOTE_LABEL ) ); |
|
510 } |
|
511 break; |
|
512 } |
|
513 // Voip call ongoing |
|
514 case EPSCTsyCallTypeVoIP: |
|
515 { |
|
516 unsupported = ETrue; |
|
517 |
|
518 if ( aShowNote ) |
|
519 { |
|
520 // If the note fails, it's no big deal |
|
521 TRAP_IGNORE( ShowUnsupportedCallTypeNoteL( |
|
522 R_VR_INTERNET_CALL_INFONOTE_LABEL ) ); |
|
523 } |
|
524 break; |
|
525 } |
|
526 } |
|
527 |
|
528 return unsupported; |
|
529 } |
|
530 |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // VRUtils::ShowMemoryFullConfirmationQueryL |
|
534 // |
|
535 // --------------------------------------------------------------------------- |
|
536 // |
|
537 void VRUtils::ShowMemoryFullConfirmationQueryL( TBool aMmc ) |
|
538 { |
|
539 CAknGlobalNote* note = NULL; |
|
540 |
|
541 note = CAknGlobalNote::NewLC(); |
|
542 |
|
543 HBufC* label = NULL; |
|
544 TInt noteId( 0 ); |
|
545 if ( aMmc ) |
|
546 { |
|
547 noteId = R_VR_MEMORY_MMC_WARNING; |
|
548 } |
|
549 else |
|
550 { |
|
551 noteId = R_VR_MEMORY_WARNING; |
|
552 } |
|
553 |
|
554 label = StringLoader::LoadLC( noteId ); |
|
555 |
|
556 note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY ); |
|
557 note->ShowNoteL( EAknGlobalWarningNote, *label ); |
|
558 CleanupStack::PopAndDestroy( 2 ); // label, note; |
|
559 } |
|
560 |
|
561 |
|
562 // --------------------------------------------------------------------------- |
|
563 // VRUtils::ShowUnsupportedCallTypeNoteL |
|
564 // |
|
565 // --------------------------------------------------------------------------- |
|
566 // |
|
567 void VRUtils::ShowUnsupportedCallTypeNoteL( TInt aResourceId ) |
|
568 { |
|
569 CAknInformationNote* infoNote; |
|
570 HBufC* noteText; |
|
571 |
|
572 noteText = CEikonEnv::Static()-> |
|
573 AllocReadResourceLC( aResourceId ); |
|
574 |
|
575 infoNote = new( ELeave ) CAknInformationNote( ETrue ); |
|
576 infoNote->ExecuteLD( *noteText ); |
|
577 |
|
578 CleanupStack::PopAndDestroy( noteText ); |
|
579 } |
|
580 |
|
581 |
|
582 // --------------------------------------------------------------------------- |
|
583 // VRUtils::MaxLengthL |
|
584 // |
|
585 // --------------------------------------------------------------------------- |
|
586 // |
|
587 EXPORT_C TInt VRUtils::MaxLengthL() |
|
588 { |
|
589 // If no value can be retrieved, use 60 minutes as max length |
|
590 TInt value( 0 ); |
|
591 |
|
592 #ifdef __AAC_ENCODER_PLUGIN // mp4 is supported now. |
|
593 if (QualityL() == EQualityHigh) |
|
594 { |
|
595 TRAPD( err, value = SettingValueL( KVRAacRecordLength, |
|
596 KVRDefaultAacRecordLength ) ); |
|
597 |
|
598 if ( err || value <= 0 || value > 9999 ) |
|
599 { |
|
600 return KVRDefaultAacRecordLength; |
|
601 } |
|
602 } |
|
603 #endif |
|
604 TRAPD( err, value = SettingValueL( KVRMaxRecordTime, |
|
605 KVRDefaultMaxLength ) ); |
|
606 |
|
607 if ( err || value <= 0 || value > 9999 ) |
|
608 { |
|
609 return KVRDefaultMaxLength; |
|
610 } |
|
611 |
|
612 |
|
613 return value; |
|
614 } |
|
615 |
|
616 |
|
617 // --------------------------------------------------------------------------- |
|
618 // VRUtils::FeatureEnabled |
|
619 // |
|
620 // --------------------------------------------------------------------------- |
|
621 // |
|
622 EXPORT_C TBool VRUtils::FeatureEnabled( TVRFeature aFeature ) |
|
623 { |
|
624 TBool ret( EFalse ); |
|
625 TInt data( 0 ); |
|
626 |
|
627 TRAPD( err, data = SettingValueL( KVRVariationFlags, 0 ) ); |
|
628 if( err != KErrNone ) |
|
629 { |
|
630 return EFalse; |
|
631 } |
|
632 |
|
633 // Compare feature to bitmask |
|
634 if ( data & aFeature ) |
|
635 { |
|
636 ret = ETrue; |
|
637 } |
|
638 return ret; |
|
639 } |
|
640 |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // VRUtils::GenerateUniqueFilename |
|
644 // Generates unique filename that doesn't exist in the directories where VR |
|
645 // operates in. Unique filename is generated in Media Gallery sense so that no |
|
646 // two sound clips can have same name there |
|
647 // --------------------------------------------------------------------------- |
|
648 // |
|
649 EXPORT_C void VRUtils::GenerateUniqueFilenameL( RFs& aFs, TFileName& aName, |
|
650 TVRFiletype aType ) |
|
651 { |
|
652 |
|
653 TBuf< VRLABELMAXLENGTH > valueStr; |
|
654 TBuf< VRLABELMAXLENGTH > formatStr; |
|
655 TFileName name( aName ); |
|
656 TFileName clipName; // Used for file existence checking |
|
657 TBool fileExists( EFalse ); |
|
658 |
|
659 // Get current count from cenrep |
|
660 TInt value( MemoCount() ); |
|
661 |
|
662 TBool uniqueFound( EFalse ); |
|
663 |
|
664 // First memo |
|
665 if ( !value ) |
|
666 { |
|
667 StringLoader::Load( formatStr, R_VOREC_FIRST_MEMO_NAME ); |
|
668 name.Append( formatStr ); |
|
669 clipName.Append( formatStr ); |
|
670 |
|
671 TRAPD( err1, fileExists = DoesFileExistL( aFs, clipName ) ); |
|
672 if ( err1 ) |
|
673 { |
|
674 // if error occurs, no much to do->generate new filename |
|
675 fileExists = ETrue; |
|
676 } |
|
677 |
|
678 AppendExtension( name, aType ); |
|
679 |
|
680 if ( fileExists ) |
|
681 { |
|
682 // Memo exists, continue name generation with next name |
|
683 ++value; |
|
684 } |
|
685 else |
|
686 { |
|
687 uniqueFound = ETrue; |
|
688 ++value; // This is saved to cenrep |
|
689 } |
|
690 } |
|
691 |
|
692 // Continue generation |
|
693 if ( !uniqueFound ) |
|
694 { |
|
695 StringLoader::Load( formatStr, R_VOREC_DEFAULT_MEMO_NAME ); |
|
696 |
|
697 |
|
698 // Loop until unique filename is generated |
|
699 FOREVER |
|
700 { |
|
701 // 0 is added before clip number when number is between 1 and 9 |
|
702 if(value >= 1 && value <= 9) |
|
703 { |
|
704 valueStr.Format( KVROneToNineClipCountFormat, value); |
|
705 } |
|
706 // no addings for clip numbers 10-> |
|
707 else |
|
708 { |
|
709 valueStr.Format( KVRDefaultClipCountFormat, value); |
|
710 } |
|
711 |
|
712 StringLoader::Format( name, formatStr, -1, valueStr ); |
|
713 |
|
714 // name copied before the path is added |
|
715 clipName = name; |
|
716 |
|
717 // Insert path to beginning |
|
718 name.Insert( 0, aName ); |
|
719 |
|
720 AknTextUtils::LanguageSpecificNumberConversion( name ); |
|
721 |
|
722 TRAPD( err2, fileExists = DoesFileExistL( aFs, clipName ) ); |
|
723 if ( err2 ) |
|
724 { |
|
725 fileExists = ETrue; |
|
726 } |
|
727 |
|
728 AppendExtension( name, aType ); |
|
729 if ( !fileExists ) |
|
730 { |
|
731 // Accept the name and increase value |
|
732 // Value increasing is mandatory to prevent similarly named clips when quality |
|
733 // or store place is changed |
|
734 ++value; |
|
735 break; |
|
736 } |
|
737 // Try next... |
|
738 ++value; |
|
739 } |
|
740 } |
|
741 |
|
742 aName = name; |
|
743 |
|
744 // Save the new value to cenrep |
|
745 SetMemoCount( value ); |
|
746 } |
|
747 |
|
748 |
|
749 // --------------------------------------------------------------------------- |
|
750 // VRUtils::AppendExtension |
|
751 // |
|
752 // --------------------------------------------------------------------------- |
|
753 // |
|
754 void VRUtils::AppendExtension( TFileName& aName, TVRFiletype aType ) |
|
755 { |
|
756 switch ( aType ) |
|
757 { |
|
758 case EVRFileWav: |
|
759 { |
|
760 aName.Append( KVRWAVFileNameExtension ); |
|
761 break; |
|
762 } |
|
763 |
|
764 //Jeffery: the following case added for the new CR |
|
765 #ifdef __AAC_ENCODER_PLUGIN |
|
766 case EVRFileAAC_LC: |
|
767 { |
|
768 aName.Append( KVRAAC_LCFileNameExtension ); |
|
769 break; |
|
770 } |
|
771 #endif |
|
772 |
|
773 // In error case amr extension is appended |
|
774 case EVRFileAmr: |
|
775 default: |
|
776 { |
|
777 aName.Append( KVRAMRFileNameExtension ); |
|
778 break; |
|
779 } |
|
780 } |
|
781 } |
|
782 |
|
783 |
|
784 // --------------------------------------------------------------------------- |
|
785 // VRUtils::MemoCount |
|
786 // |
|
787 // --------------------------------------------------------------------------- |
|
788 // |
|
789 EXPORT_C TInt VRUtils::MemoCount() |
|
790 { |
|
791 // If no value can be retrieved, use zero |
|
792 TInt value( 0 ); |
|
793 TRAPD( err, value = SettingValueL( KVRMemoCount, 0 ) ); |
|
794 if ( err != KErrNone ) |
|
795 { |
|
796 return 0; |
|
797 } |
|
798 return value; |
|
799 } |
|
800 |
|
801 |
|
802 // --------------------------------------------------------------------------- |
|
803 // VRUtils::SetMemoCount |
|
804 // |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 EXPORT_C void VRUtils::SetMemoCount( TInt aNewCount ) |
|
808 { |
|
809 TRAP_IGNORE( SetSettingValueL( KVRMemoCount, aNewCount ) ); |
|
810 } |
|
811 |
|
812 |
|
813 // --------------------------------------------------------------------------- |
|
814 // VRUtils::AMRBitrateL |
|
815 // |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 EXPORT_C TUint VRUtils::AMRBitrateL() |
|
819 { |
|
820 TUint bitrate(KVRDefaultAmrBitrate); |
|
821 |
|
822 // Fetch bitrate from |
|
823 TRAPD( err, bitrate = SettingValueL( KVRBitrateAmr, |
|
824 KVRDefaultAmrBitrate ) ); |
|
825 |
|
826 if ( err || bitrate <= 0 || bitrate > 12200 ) |
|
827 { |
|
828 bitrate = KVRDefaultAmrBitrate; |
|
829 } |
|
830 |
|
831 return bitrate; |
|
832 } |
|
833 |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // VRUtils::AACBitrateL |
|
837 // |
|
838 // --------------------------------------------------------------------------- |
|
839 // |
|
840 EXPORT_C TUint VRUtils::AACBitrateL() |
|
841 { |
|
842 |
|
843 TUint bitrate(KVRDefaultBitrateAac); |
|
844 |
|
845 // Fetch bitrate from |
|
846 TRAPD( err, bitrate = SettingValueL( KVRBitrateAac, |
|
847 KVRDefaultBitrateAac ) ); |
|
848 |
|
849 if ( err || bitrate <= 8000 || bitrate > 288000 ) |
|
850 { |
|
851 bitrate = KVRDefaultBitrateAac; |
|
852 } |
|
853 return bitrate; |
|
854 } |
|
855 |
|
856 // --------------------------------------------------------------------------- |
|
857 // VRUtils::DoesFileExistL |
|
858 // Makes the full checking if the filename (aName) exists in the directories |
|
859 // that Voice Recorder uses for clip storage |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 TBool VRUtils::DoesFileExistL( RFs& aFs, TFileName aName ) |
|
863 { |
|
864 // old memory storage |
|
865 #ifndef RD_MULTIPLE_DRIVE |
|
866 // Storage place at the moment |
|
867 TVRMemoStore memoStore = MemoStoreL(); |
|
868 TFileName path; |
|
869 TFileName fileName(aName); |
|
870 |
|
871 // The path for the current storage place |
|
872 VRUtils::MemoStoreDirectoryL( path ); |
|
873 |
|
874 // Add the path to the filename |
|
875 fileName.Insert( 0, path ); |
|
876 |
|
877 if ( CheckFileExistence( aFs, fileName ) ) |
|
878 { |
|
879 return ETrue; |
|
880 } |
|
881 |
|
882 // Check possible alternative storage place |
|
883 TVRMemoStore secondaryStore; |
|
884 if ( memoStore == EMemoStorePhoneMemory ) |
|
885 { |
|
886 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
887 { |
|
888 secondaryStore = EMemoStoreMMC; |
|
889 } |
|
890 else |
|
891 { |
|
892 secondaryStore = EMemoStorePhoneMemory; |
|
893 } |
|
894 } |
|
895 else |
|
896 { |
|
897 secondaryStore = EMemoStorePhoneMemory; |
|
898 } |
|
899 |
|
900 // If there is some secondary storage place to check |
|
901 if( memoStore != secondaryStore ) |
|
902 { |
|
903 // Temporarily change the storage place (needed by MemoStoreDirectoryL) |
|
904 VRUtils::SetSettingValueL( KVRMemoStore, secondaryStore ); |
|
905 |
|
906 // Retrieve the path and add it to the filename |
|
907 VRUtils::MemoStoreDirectoryL( path ); |
|
908 |
|
909 fileName = aName; |
|
910 fileName.Insert( 0, path ); |
|
911 |
|
912 // Change back to the original |
|
913 VRUtils::SetSettingValueL( KVRMemoStore, memoStore ); |
|
914 |
|
915 if ( CheckFileExistence( aFs, fileName ) ) |
|
916 { |
|
917 return ETrue; |
|
918 } |
|
919 } |
|
920 |
|
921 // for multiple drives |
|
922 #else |
|
923 TFileName path; |
|
924 TFileName fileName(aName); |
|
925 |
|
926 TDriveList allDrives; |
|
927 TInt allDriveCount( 0 ); |
|
928 |
|
929 User::LeaveIfError(DriveInfo::GetUserVisibleDrives( aFs, allDrives, allDriveCount )); |
|
930 |
|
931 TInt max( allDrives.Length()); |
|
932 for ( TInt i = 0; i < max; i++ ) |
|
933 { |
|
934 if ( allDrives[ i ] ) |
|
935 { |
|
936 TUint status( 0 ); |
|
937 VRUtils::GetDriveInfo( i, status); |
|
938 |
|
939 if( status & DriveInfo::EDriveRemote ) |
|
940 { |
|
941 continue; |
|
942 } |
|
943 |
|
944 User::LeaveIfError( PathInfo::GetRootPath( path, i) ); |
|
945 path.Append( PathInfo::DigitalSoundsPath() ); |
|
946 |
|
947 // Add the path to the filename |
|
948 fileName.Insert( 0, path ); |
|
949 |
|
950 if ( CheckFileExistence( aFs, fileName ) ) |
|
951 { |
|
952 return ETrue; |
|
953 } |
|
954 |
|
955 fileName.Copy(aName); |
|
956 } |
|
957 } |
|
958 #endif |
|
959 |
|
960 return EFalse; |
|
961 |
|
962 } |
|
963 |
|
964 |
|
965 // --------------------------------------------------------------------------- |
|
966 // VRUtils::CheckFileExistence |
|
967 // Checks if the filename given as a parameter exists. This function checks all |
|
968 // possible extensions (in VR). Note that aName includes path but no extension. |
|
969 // --------------------------------------------------------------------------- |
|
970 // |
|
971 TBool VRUtils::CheckFileExistence( RFs& aFs, TFileName aName ) |
|
972 { |
|
973 TFileName fileName( aName ); |
|
974 |
|
975 // AMR file |
|
976 AppendExtension( fileName, EVRFileAmr ); |
|
977 AknTextUtils::LanguageSpecificNumberConversion( fileName ); |
|
978 if ( BaflUtils::FileExists( aFs, fileName ) ) |
|
979 { |
|
980 return ETrue; |
|
981 } |
|
982 |
|
983 // WAV file |
|
984 fileName = aName; |
|
985 AppendExtension( fileName, EVRFileWav ); |
|
986 AknTextUtils::LanguageSpecificNumberConversion( fileName ); |
|
987 if ( BaflUtils::FileExists( aFs, fileName ) ) |
|
988 { |
|
989 return ETrue; |
|
990 } |
|
991 |
|
992 |
|
993 // AAC_LC file |
|
994 #ifdef __AAC_ENCODER_PLUGIN |
|
995 fileName = aName; |
|
996 AppendExtension( fileName, EVRFileAAC_LC ); |
|
997 AknTextUtils::LanguageSpecificNumberConversion( fileName ); |
|
998 |
|
999 if ( BaflUtils::FileExists( aFs, fileName ) ) |
|
1000 { |
|
1001 return ETrue; |
|
1002 } |
|
1003 #endif |
|
1004 |
|
1005 return EFalse; |
|
1006 } |
|
1007 |
|
1008 |
|
1009 // --------------------------------------------------------------------------- |
|
1010 // VRUtils::AACSamplerateL |
|
1011 // --------------------------------------------------------------------------- |
|
1012 // |
|
1013 |
|
1014 EXPORT_C TInt VRUtils::AACSamplerateL() |
|
1015 { |
|
1016 |
|
1017 TUint samplerate( KVRDefaultSamplerateAac ); |
|
1018 |
|
1019 // Fetch bitrate from |
|
1020 TRAPD( err, samplerate = SettingValueL( KVRSamplerateAac, |
|
1021 KVRDefaultSamplerateAac ) ); |
|
1022 |
|
1023 if ( err || samplerate < 8000 || samplerate > 48000 ) |
|
1024 { |
|
1025 return KVRDefaultSamplerateAac; |
|
1026 } |
|
1027 |
|
1028 |
|
1029 return samplerate; |
|
1030 } |
|
1031 |
|
1032 |
|
1033 // --------------------------------------------------------------------------- |
|
1034 // VRUtils::AACAudioModeL |
|
1035 // --------------------------------------------------------------------------- |
|
1036 // |
|
1037 |
|
1038 EXPORT_C TInt VRUtils::AACAudioModeL() |
|
1039 { |
|
1040 |
|
1041 TUint mode( KVRDefaultStereoMonoFlag ); |
|
1042 |
|
1043 // Fetch audiomode from |
|
1044 TRAPD( err, mode = SettingValueL( KVRStereoMonoFlag, |
|
1045 KVRDefaultStereoMonoFlag ) ); |
|
1046 |
|
1047 if ( err || (mode != 1 && mode != 2)) |
|
1048 { |
|
1049 return KVRDefaultStereoMonoFlag; |
|
1050 } |
|
1051 |
|
1052 |
|
1053 return mode; |
|
1054 } |
|
1055 |
|
1056 |
|
1057 #ifdef RD_MULTIPLE_DRIVE |
|
1058 // --------------------------------------------------------------------------- |
|
1059 // VRUtils::SetMemoDriveL |
|
1060 // |
|
1061 // --------------------------------------------------------------------------- |
|
1062 // |
|
1063 EXPORT_C void VRUtils::SetMemoDriveL( TDriveNumber aDrive ) |
|
1064 { |
|
1065 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
1066 { |
|
1067 SetSettingValueL( KVRMemoStore, aDrive ); |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 __ASSERT_DEBUG( ETrue, User::Panic( KVRPanic, EPanicInvalidSetting ) ); |
|
1072 } |
|
1073 } |
|
1074 |
|
1075 |
|
1076 // --------------------------------------------------------------------------- |
|
1077 // VRUtils::MemoDriveL |
|
1078 // |
|
1079 // --------------------------------------------------------------------------- |
|
1080 // |
|
1081 EXPORT_C TInt VRUtils::MemoDriveL() |
|
1082 { |
|
1083 TInt defaultDrive = DefaultMemoDriveL(); |
|
1084 // Phone memory is the default |
|
1085 if ( FeatureManager::FeatureSupported( KFeatureIdMmc ) ) |
|
1086 { |
|
1087 TInt ret = SettingValueL( KVRMemoStore, |
|
1088 defaultDrive ); |
|
1089 return static_cast< TInt >( ret ); |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 return defaultDrive; |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // VRUtils::DefaultMemoDriveL |
|
1100 // |
|
1101 // --------------------------------------------------------------------------- |
|
1102 // |
|
1103 EXPORT_C TInt VRUtils::DefaultMemoDriveL() |
|
1104 { |
|
1105 TInt drive(0); |
|
1106 User::LeaveIfError( DriveInfo::GetDefaultDrive(DriveInfo::EDefaultPhoneMemory, drive ) ); |
|
1107 return drive; |
|
1108 } |
|
1109 |
|
1110 |
|
1111 // --------------------------------------------------------------------------- |
|
1112 // VRUtils::Get drive Info |
|
1113 // it is for multiple drive feature |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // |
|
1116 EXPORT_C void VRUtils::GetDriveInfo( TInt aDrive, TUint& aDriveInfo ) |
|
1117 { |
|
1118 RFs& iFs = CCoeEnv::Static()->FsSession() ; |
|
1119 DriveInfo::GetDriveStatus( iFs, aDrive, aDriveInfo ); |
|
1120 } |
|
1121 #endif |
|
1122 |
|
1123 |
|
1124 // End of File |