|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Implementation of CProEngMediaVariation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CProEngMediaVariation.h" |
|
22 #include <centralrepository.h> |
|
23 #include <apgcli.h> // RApaLsSession |
|
24 #include "ProfileEngineInternalCRKeys.h" |
|
25 #include "ProEngMmfInfoUtility.h" |
|
26 #include "MProfileUtilitySingleton.h" |
|
27 #include "MProfilesLocalFeatures.h" |
|
28 |
|
29 namespace |
|
30 { |
|
31 // CONSTANTS |
|
32 _LIT( KProEngVideoMimeType, "video/*" ); |
|
33 _LIT( KProEngRMVideoMimeType, "application/vnd.rn-realmedia" ); |
|
34 _LIT( KProEngSDPVideoMimeType, "application/sdp" ); |
|
35 #ifdef RD_VIDEO_AS_RINGING_TONE |
|
36 const TInt KProEngFeatureIdVideoAsRingingTone( 1 ); |
|
37 #else |
|
38 const TInt KProEngFeatureIdVideoAsRingingTone( 0 ); |
|
39 #endif |
|
40 } |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CProEngMediaVariation::CProEngMediaVariation |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CProEngMediaVariation::CProEngMediaVariation() |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CProEngMediaVariation::ConstructL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CProEngMediaVariation::ConstructL() |
|
57 { |
|
58 User::LeaveIfError( iApaLsSession.Connect() ); |
|
59 |
|
60 // Singleton must be released in destructor |
|
61 iLocalFeatures = &( ProfileUtilityInstanceL().ProfilesLocalFeatures() ); |
|
62 |
|
63 const TInt KProEngMimesGranularity( 10 ); |
|
64 iSupportedMimeTypes = new ( ELeave ) CDesC8ArrayFlat( |
|
65 KProEngMimesGranularity ); |
|
66 iMimeTypeBuf.CreateL( KMaxDataTypeLength ); |
|
67 ProEngMmfInfoUtility::GetSupportedMimeTypesL( *iSupportedMimeTypes ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CProEngMediaVariation::NewL |
|
72 // Two-phased constructor. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CProEngMediaVariation* CProEngMediaVariation::NewL() |
|
76 { |
|
77 CProEngMediaVariation* self = |
|
78 new ( ELeave ) CProEngMediaVariation(); |
|
79 |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 |
|
84 return self; |
|
85 } |
|
86 |
|
87 // Destructor |
|
88 CProEngMediaVariation::~CProEngMediaVariation() |
|
89 { |
|
90 delete iSupportedMimeTypes; |
|
91 iMimeTypeBuf.Close(); |
|
92 iApaLsSession.Close(); |
|
93 |
|
94 if ( iLocalFeatures ) |
|
95 { |
|
96 ReleaseProfileUtility(); |
|
97 } |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CProEngMediaVariation::DataTypeL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CProEngMediaVariation::GetDataTypeL( |
|
105 const TDesC& aFileName, TDes16& aDataType ) const |
|
106 { |
|
107 TUid dummyUid = { 0 }; // instantiate as zero |
|
108 TDataType dataType( dummyUid ); |
|
109 User::LeaveIfError( |
|
110 iApaLsSession.AppForDocument( aFileName, dummyUid, dataType ) ); |
|
111 aDataType.Copy( dataType.Des8() ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CProEngMediaVariation::IsSupported |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 TBool CProEngMediaVariation::IsSupported( const TDesC16& aMimeType ) |
|
119 { |
|
120 if( !KProEngFeatureIdVideoAsRingingTone && |
|
121 ( ( aMimeType.MatchF( KProEngVideoMimeType ) == 0 ) || |
|
122 ( aMimeType.CompareF( KProEngRMVideoMimeType ) == 0 ) || |
|
123 ( aMimeType.CompareF( KProEngSDPVideoMimeType ) == 0 ) ) ) |
|
124 { |
|
125 return EFalse; |
|
126 } |
|
127 |
|
128 if( iLocalFeatures->IsBlockedType( aMimeType ) || |
|
129 iLocalFeatures->IsExcludedType( aMimeType ) ) |
|
130 { |
|
131 return EFalse; |
|
132 } |
|
133 |
|
134 TInt ignore( 0 ); |
|
135 iMimeTypeBuf.Copy( aMimeType ); |
|
136 if( iSupportedMimeTypes->FindIsq( iMimeTypeBuf, ignore ) != KErrNone ) |
|
137 { |
|
138 return EFalse; |
|
139 } |
|
140 |
|
141 return ETrue; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CProEngMediaVariation::IsAllowedProtected |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TBool CProEngMediaVariation::IsAllowedProtected( const TDesC16& aMimeType ) |
|
149 const |
|
150 { |
|
151 return !iLocalFeatures->IsBlockedProtectedType( aMimeType ); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CProEngMediaVariation::IsAllowedUnProtected |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CProEngMediaVariation::IsAllowedUnProtected( const TDesC16& aMimeType ) |
|
159 const |
|
160 { |
|
161 return !iLocalFeatures->IsBlockedUnprotectedType( aMimeType ); |
|
162 } |
|
163 |
|
164 // End of File |
|
165 |