|
1 /* |
|
2 * Copyright (c) 2008 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: Tone/File Utility. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <apgcli.h> |
|
21 #include <DRMHelper.h> |
|
22 #include <f32file.h> |
|
23 #include <bautils.h> |
|
24 |
|
25 // User Includes |
|
26 #include "evttoneutils.h" |
|
27 #include "evtdebug.h" |
|
28 |
|
29 // Constants |
|
30 // Rich audio file MIME types |
|
31 _LIT(KAac, "audio/aac"); |
|
32 _LIT(KMp3, "audio/mp3"); |
|
33 _LIT(KMpeg, "audio/mpeg"); |
|
34 _LIT(K3gpp, "audio/3gpp"); |
|
35 _LIT(KMp4, "audio/mp4"); |
|
36 _LIT(KAmrWb, "audio/amr-wb"); |
|
37 _LIT(KWavX, "audio/x-wav"); |
|
38 _LIT(KWav, "audio/wav"); |
|
39 _LIT( KRngMimeType, "application/vnd.nokia.ringing-tone" ); |
|
40 |
|
41 // ================ Member funtions for CEvtVibraHandler class =============== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // EvtToneUtils::DataType() |
|
45 // (other items were commented in a header). |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TBool EvtToneUtils::IsRNGTypeL( const TDesC& aFileName ) |
|
49 { |
|
50 TPtrC type(EvtToneUtils::DataTypeL( aFileName ).Des()); |
|
51 |
|
52 if( type.CompareF( KRngMimeType ) == 0 ) |
|
53 return ETrue; |
|
54 else |
|
55 return EFalse; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // EvtToneUtils::IsFilePlayableL |
|
60 // (other items were commented in a header). |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 TBool EvtToneUtils::IsFilePlayableL( const TDesC& aFileName ) |
|
64 { |
|
65 TPtrC type(EvtToneUtils::DataTypeL( aFileName ).Des()); |
|
66 |
|
67 if ( type == KAac || type == KMp3 || type == KMpeg || |
|
68 type == K3gpp || type == KMp4 || type == KAmrWb || |
|
69 type == KWavX || type == KWav ) |
|
70 { |
|
71 ContentAccess::CContent* content = NULL; |
|
72 TRAPD( err, content = ContentAccess::CContent::NewL( aFileName ) ); |
|
73 if ( err == KErrNone && content ) |
|
74 { |
|
75 // ECanPlay checks rights as well as EIsProtected |
|
76 TInt canPlay( 0 ); |
|
77 content->GetAttribute( ContentAccess::ECanPlay, canPlay ); |
|
78 delete content; |
|
79 return canPlay; |
|
80 } |
|
81 return EFalse; |
|
82 } |
|
83 |
|
84 return ETrue; // Other MIMEs can be played without DRM check. |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // EvtToneUtils::DataTypeL() |
|
89 // (other items were commented in a header). |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TDataType EvtToneUtils::DataTypeL( const TDesC& aFileName ) |
|
93 { |
|
94 RApaLsSession apaLsSession; |
|
95 User::LeaveIfError( apaLsSession.Connect() ); |
|
96 CleanupClosePushL( apaLsSession ); |
|
97 |
|
98 TDataType dataType; |
|
99 TUid dummyUid( KNullUid ); |
|
100 |
|
101 User::LeaveIfError( apaLsSession.AppForDocument( aFileName, dummyUid, dataType ) ); |
|
102 |
|
103 CleanupStack::PopAndDestroy(); // apaLsSession |
|
104 |
|
105 return dataType; |
|
106 } |
|
107 // ----------------------------------------------------------------------------- |
|
108 // EvtToneUtils::IsExistL() |
|
109 // (other items were commented in a header). |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TBool EvtToneUtils::IsExistL( const TDesC& aFileName ) |
|
113 { |
|
114 TBool isPresent = EFalse; |
|
115 |
|
116 RFs fsSession; |
|
117 User::LeaveIfError(fsSession.Connect()); |
|
118 if( BaflUtils::FileExists(fsSession, aFileName) ) |
|
119 { |
|
120 isPresent = ETrue; |
|
121 } |
|
122 fsSession.Close(); |
|
123 |
|
124 return isPresent; |
|
125 } |