|
1 /* |
|
2 * Copyright (c) 2002 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 the CProfilesLocalFeatures. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CProfilesLocalFeatures.h" |
|
22 #include "ProfileEnginePrivateCRKeys.h" |
|
23 #include "ProfilesDebug.h" |
|
24 #include <centralrepository.h> |
|
25 #include <apmstd.h> |
|
26 |
|
27 namespace |
|
28 { |
|
29 _LIT( KProfilesSpace, " " ); |
|
30 } |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CProfilesLocalFeatures::CProfilesLocalFeatures |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CProfilesLocalFeatures::CProfilesLocalFeatures() |
|
41 : iFeatureBitMask( 0 ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CProfilesLocalFeatures::CProfilesLocalFeatures |
|
47 // C++ default constructor can NOT contain any code, that |
|
48 // might leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CProfilesLocalFeatures::CProfilesLocalFeatures( TInt aFeatureBitMask ) |
|
52 : iFeatureBitMask( aFeatureBitMask ) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CProfilesLocalFeatures::ConstructL |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CProfilesLocalFeatures::ConstructL() |
|
62 { |
|
63 CRepository* cenrep = CRepository::NewL( KCRUidProfilesLV ); |
|
64 CleanupStack::PushL( cenrep ); |
|
65 User::LeaveIfError( cenrep->Get( KProfilesLVFlags, iFeatureBitMask ) ); |
|
66 ReadListKeyL( *cenrep, KProEngBlockedTones, iBlockedTones ); |
|
67 ReadListKeyL( *cenrep, KProEngBlockedUnprotectedTones, |
|
68 iBlockedUnprotectedTones ); |
|
69 ReadListKeyL( *cenrep, KProEngBlockedProtectedTones, |
|
70 iBlockedProtectedTones ); |
|
71 ReadListKeyL( *cenrep, KProEngBlockedDemoPlayTones, |
|
72 iBlockedDemoPlayTones ); |
|
73 ReadListKeyL( *cenrep, KProEngExcludedTones, |
|
74 iExcludedTones ); |
|
75 CleanupStack::PopAndDestroy(); // cenrep |
|
76 if( ( iBlockedTones.Length() > 0 ) || |
|
77 ( iBlockedUnprotectedTones.Length() > 0 ) || |
|
78 ( iBlockedProtectedTones.Length() > 0 ) ) |
|
79 { |
|
80 iMimeBuf.CreateL( KMaxDataTypeLength + KProfilesSpace().Length() ); |
|
81 } |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CProfilesLocalFeatures::NewL |
|
86 // |
|
87 // (other items were commented in a header). |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CProfilesLocalFeatures* CProfilesLocalFeatures::NewL() |
|
91 { |
|
92 CProfilesLocalFeatures* self = new ( ELeave ) CProfilesLocalFeatures(); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(); // self |
|
96 return self; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CProfilesLocalFeatures::NewL |
|
101 // |
|
102 // (other items were commented in a header). |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CProfilesLocalFeatures* CProfilesLocalFeatures::NewL( |
|
106 CProfilesLocalFeatures& aLocalFeatures ) |
|
107 { |
|
108 return new ( ELeave ) |
|
109 CProfilesLocalFeatures( aLocalFeatures.iFeatureBitMask ); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CProfilesLocalFeatures::IsFeatureSupported |
|
114 // |
|
115 // (other items were commented in a header). |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 TBool CProfilesLocalFeatures::IsFeatureSupported( TInt aLocalFeatureId ) const |
|
119 { |
|
120 return iFeatureBitMask & aLocalFeatureId; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CProfilesLocalFeatures::IsBlockedType |
|
125 // |
|
126 // (other items were commented in a header). |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 TBool CProfilesLocalFeatures::IsBlockedType( const TDesC& aMimeType ) |
|
130 { |
|
131 return ContainsMimeType( iBlockedTones, aMimeType ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CProfilesLocalFeatures::IsBlockedUnprotectedType |
|
136 // |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TBool CProfilesLocalFeatures::IsBlockedUnprotectedType( |
|
141 const TDesC& aMimeType ) |
|
142 { |
|
143 return ContainsMimeType( iBlockedUnprotectedTones, aMimeType ); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CProfilesLocalFeatures::IsBlockedProtectedType |
|
148 // |
|
149 // (other items were commented in a header). |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 TBool CProfilesLocalFeatures::IsBlockedProtectedType( const TDesC& aMimeType ) |
|
153 { |
|
154 return ContainsMimeType( iBlockedProtectedTones, aMimeType ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CProfilesLocalFeatures::IsBlockedDemoPlayType |
|
159 // |
|
160 // (other items were commented in a header). |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TBool CProfilesLocalFeatures::IsBlockedDemoPlayType( const TDesC& aMimeType ) |
|
164 { |
|
165 return ContainsMimeType( iBlockedDemoPlayTones, aMimeType ); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CProfilesLocalFeatures::IsExcludedType |
|
170 // |
|
171 // (other items were commented in a header). |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 TBool CProfilesLocalFeatures::IsExcludedType( const TDesC& aMimeType ) |
|
175 { |
|
176 return ContainsMimeType( iExcludedTones, aMimeType ); |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CProfilesLocalFeatures::ReadListKeyL |
|
181 // |
|
182 // (other items were commented in a header). |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CProfilesLocalFeatures::ReadListKeyL( CRepository& aCenRep, |
|
186 TUint32 aKey, |
|
187 RBuf& aValue ) |
|
188 { |
|
189 TBuf<1> tmp; // Magic: 1 char to get length of actual value |
|
190 TInt realLen = 0; |
|
191 TInt err = aCenRep.Get( aKey, tmp, realLen ); |
|
192 if ( err == KErrOverflow ) |
|
193 { |
|
194 // Prepare list of blocked MIME types |
|
195 aValue.CreateL( realLen + KProfilesSpace().Length() ); |
|
196 User::LeaveIfError( aCenRep.Get( aKey, aValue ) ); |
|
197 aValue.Append( KProfilesSpace ); |
|
198 } |
|
199 else |
|
200 { |
|
201 User::LeaveIfError( err ); |
|
202 } |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CProfilesLocalFeatures::ContainsMimeTypeL |
|
207 // |
|
208 // (other items were commented in a header). |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TBool CProfilesLocalFeatures::ContainsMimeType( const TDesC& aList, |
|
212 const TDesC& aMimeType ) |
|
213 { |
|
214 if( aList.Length() == 0 ) |
|
215 { |
|
216 PRODEBUG( |
|
217 "CProfilesLocalFeatures::ContainsMimeTypeL(), return false" ); |
|
218 return EFalse; |
|
219 } |
|
220 |
|
221 TBool ret( EFalse ); |
|
222 iMimeBuf.Copy( aMimeType ); |
|
223 // FindF() would find "audio/3gpp" in "audio/3gpp2" without |
|
224 // the added space. |
|
225 iMimeBuf.Append( KProfilesSpace ); |
|
226 |
|
227 // If result is not KErrNotFound, this MIME-type is indeed blocked |
|
228 ret = ( aList.FindF( iMimeBuf ) >= 0 ); |
|
229 |
|
230 PRODEBUG3( "CProfilesLocalFeatures::ContainsMimeTypeL(%S,%S), returning %d", |
|
231 &aList, &aMimeType, ret ); |
|
232 return ret; |
|
233 } |
|
234 |
|
235 CProfilesLocalFeatures::~CProfilesLocalFeatures() |
|
236 { |
|
237 iBlockedTones.Close(); |
|
238 iBlockedUnprotectedTones.Close(); |
|
239 iBlockedProtectedTones.Close(); |
|
240 iBlockedDemoPlayTones.Close(); |
|
241 iExcludedTones.Close(); |
|
242 iMimeBuf.Close(); |
|
243 } |
|
244 |
|
245 // End of File |
|
246 |