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: A helper interface to be used by S60 applications for |
|
15 * setting ringing and alert tones for different profiles. |
|
16 * Registers DRM protected tones as automated content |
|
17 * and removes old content from automated content list. |
|
18 * Shows a content activation query if necessary. |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CPROFILETONEHANDLER_H |
|
25 #define CPROFILETONEHANDLER_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <f32file.h> // CBase, RFs |
|
29 #include <MSSSettingsObserver.h> // MSSSettingsObserver, RSSSettings |
|
30 #include <apmstd.h> // KMaxDataTypeLength |
|
31 #include <data_caging_path_literals.hrh> |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 /** |
|
36 * Enumerations for different tone settings in Profiles. |
|
37 * Should there become a need e.g. for separately place line 1 and line 2 |
|
38 * ringing tones, we just add them to these enumerations. |
|
39 */ |
|
40 enum TProfileTones |
|
41 { |
|
42 EProfileRingingToneSetting = 1, |
|
43 EProfileVideoCallToneSetting = 2, |
|
44 EProfileMessageAlertToneSetting = 3, |
|
45 EProfileInstantMessageAlertToneSetting = 4, |
|
46 EProfileEmailAlertToneSetting = 5 |
|
47 }; |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 class DRMCommon; |
|
51 class CDRMHelper; |
|
52 class MProfileExtended; |
|
53 class MProfileEngineExtended; |
|
54 class MProfilesLocalFeatures; |
|
55 |
|
56 // CLASS DECLARATION |
|
57 |
|
58 /** |
|
59 * A helper interface to be used by S60 applications for |
|
60 * setting ringing and alert tones for different profiles. |
|
61 * Registers DRM protected tones as automated content |
|
62 * and removes old content from automated content list. |
|
63 * Shows a content activation query and other DRM related |
|
64 * notes if necessary. |
|
65 |
|
66 * |
|
67 * @lib ProfileSettingsView.lib |
|
68 * @since Series 60 2.6 |
|
69 */ |
|
70 class CProfileToneHandler : public CBase, public MSSSettingsObserver |
|
71 { |
|
72 public: // Constructors and destructor |
|
73 |
|
74 // Two-phased constructors. |
|
75 IMPORT_C static CProfileToneHandler* NewL(); |
|
76 IMPORT_C static CProfileToneHandler* NewLC(); |
|
77 |
|
78 // Destructor. |
|
79 ~CProfileToneHandler(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Sets the ringing tone of the current active profile. |
|
85 * If the file does not exist, leaves with KErrNotFound. |
|
86 * If the file is of an unsupported type, leaves with KErrNotSupported. |
|
87 * If the file is an unprotected MP3/AAC in user data area |
|
88 * and if those are not allowed as ringing or alert tones, |
|
89 * leaves with KErrPermissionDenied. |
|
90 * If the file is a WMA file in user data area and those are not |
|
91 * allowed, leaves with KErrArgument. |
|
92 * If the active profile is not allowed to be changed |
|
93 * (e.g. Drive-profile) leaves with KErrAccessDenied. |
|
94 * If Alternate Line Service is enabled, finds out the line in use |
|
95 * and sets the ringing tone for that line respectively. |
|
96 * @since 2.6 |
|
97 * @param aFileName Full path and filename of the tone to be used |
|
98 * as the new ringing tone. An empty descriptor |
|
99 * will be replaced with "No_Sound.wav". |
|
100 * @return KErrNone if successful, |
|
101 * KErrCancel if user answers No to a DRM activation query. |
|
102 * (See DRMHelper::SetAutomatedPassive) |
|
103 * KErrGeneral if DRM rights are insufficient. |
|
104 * KErrArgument if the file is DRM protected |
|
105 * audio/mp4 and those are not allowed as ringingtones. |
|
106 */ |
|
107 IMPORT_C TInt SetActiveProfileRingingToneL( const TDesC& aFileName ); |
|
108 |
|
109 /** |
|
110 * Sets a ringing or alert tone for a profile. |
|
111 * If the file does not exist, leaves with KErrNotFound. |
|
112 * If the file is of an unsupported type, leaves with KErrNotSupported. |
|
113 * If the file is an unprotected MP3/AAC in user data area |
|
114 * and if those are not allowed as ringing or alert tones, |
|
115 * leaves with KErrPermissionDenied. |
|
116 * If the file is a WMA file in user data area and those are not |
|
117 * allowed, leaves with KErrArgument. |
|
118 * If the file is not allowed to be changed |
|
119 * leaves with KErrAccessDenied. |
|
120 * If the selected profile is not allowed to be changed |
|
121 * (e.g. Drive-profile) leaves with KErrAccessDenied. |
|
122 * In case of a ringing tone, if Alternate Line Service is enabled, |
|
123 * finds out the line in use and sets the ringing tone for that |
|
124 * line respectively. |
|
125 * @since 2.6 |
|
126 * @param aProfileId The ID of the profile (NOT an index). |
|
127 * @param aToneSetting Identifies the tone which is updated. |
|
128 * @param aFileName Full path and filename of the tone to be used |
|
129 * as the new ringing or alert tone. An empty descriptor |
|
130 * will be replaced with "No_Sound.wav". |
|
131 * @return Returns KErrNone if successful, |
|
132 * KErrCancel if user answers No to a DRM activation query. |
|
133 * (See DRMHelper::SetAutomatedPassive) |
|
134 * KErrGeneral if DRM rights are insufficient. |
|
135 * KErrArgument if the file is DRM protected |
|
136 * audio/mp4 and those are not allowed as ringingtones. |
|
137 */ |
|
138 IMPORT_C TInt SetProfileToneL( TInt aProfileId, |
|
139 TProfileTones aToneSetting, const TDesC& aFileName ); |
|
140 |
|
141 /** |
|
142 * Sets a ringing or alert tone for a profile and not check the file. |
|
143 * This function only can be used when user set a ringing or alert tone |
|
144 * for some profiles and avoid to repeat check the file. |
|
145 * Notice: the SetProfileToneL should be executed before this function, because |
|
146 * SetProfileToneL will check the file. |
|
147 * leaves with KErrPermissionDenied. |
|
148 * If the file is a WMA file in user data area and those are not |
|
149 * allowed, leaves with KErrArgument. |
|
150 * If the file is not allowed to be changed |
|
151 * leaves with KErrAccessDenied. |
|
152 * If the selected profile is not allowed to be changed |
|
153 * (e.g. Drive-profile) leaves with KErrAccessDenied. |
|
154 * In case of a ringing tone, if Alternate Line Service is enabled, |
|
155 * finds out the line in use and sets the ringing tone for that |
|
156 * line respectively. |
|
157 * @param aProfileId The ID of the profile (NOT an index). |
|
158 * @param aToneSetting Identifies the tone which is updated. |
|
159 * @param aFileName Full path and filename of the tone to be used |
|
160 * as the new ringing or alert tone. An empty descriptor |
|
161 * will be replaced with "No_Sound.wav". |
|
162 * @return Returns KErrNone this function didn't check the file, so return KErrNone. |
|
163 */ |
|
164 IMPORT_C TInt SetProfileToneNotCheckL( TInt aProfileId, |
|
165 TProfileTones aToneSetting, const TDesC& aFileName ); |
|
166 |
|
167 /** |
|
168 * Sets a ringing or alert tone for all profiles. |
|
169 * If the file does not exist, leaves with KErrNotFound. |
|
170 * If the file is of an unsupported type, leaves with KErrNotSupported. |
|
171 * If the file is an unprotected MP3/AAC in user data area |
|
172 * and if those are not allowed as ringing or alert tones, |
|
173 * leaves with KErrPermissionDenied. |
|
174 * If the file is a WMA file in user data area and those are not |
|
175 * allowed, leaves with KErrArgument. |
|
176 * If the file is not allowed to be changed |
|
177 * (e.g. Drive-profile) method ignores profile changes |
|
178 * and selects next profile. |
|
179 * In case of a ringing tone, if Alternate Line Service is enabled, |
|
180 * finds out the line in use and sets the ringing tone for that |
|
181 * line respectively. |
|
182 * Does not affect on user created profiles except if the active profile |
|
183 * is user created of which the ringing or alert tone is also changed. |
|
184 * @since 2.6 |
|
185 * @param aToneSetting Identifies the tone which is updated. |
|
186 * @param aFileName Full path and filename of the tone to be used |
|
187 * as the new ringing or alert tone. An empty descriptor |
|
188 * will be replaced with "No_Sound.wav". |
|
189 * @return Returns KErrNone if successful, |
|
190 * KErrCancel if user answers No to a DRM activation query. |
|
191 * (See DRMHelper::SetAutomatedPassive) |
|
192 * KErrGeneral if DRM rights are insufficient. |
|
193 * KErrArgument if the file is DRM protected |
|
194 * audio/mp4 and those are not allowed as ringingtones. |
|
195 */ |
|
196 IMPORT_C TInt SetToneForAllProfilesL( TProfileTones aToneSetting, |
|
197 const TDesC& aFileName ); |
|
198 |
|
199 public: // From base classes |
|
200 |
|
201 /** |
|
202 * From MSSSettings |
|
203 */ |
|
204 void PhoneSettingChanged( TSSSettingsSetting aSetting, TInt aNewValue ); |
|
205 |
|
206 protected: // New functions |
|
207 |
|
208 /** |
|
209 * Stores the settings to Profiles Engine and adds the file to automated |
|
210 * content list and removes the old file from automated content list. |
|
211 * Do not call until the file is checked using CheckFileL. |
|
212 * @param aProfileId The ID of the profile (NOT an index). |
|
213 * @param aToneSetting Identifies the tone which is updated. |
|
214 * @param aFileName Full path and filename of the tone to be used |
|
215 * as the new ringing or alert tone. |
|
216 */ |
|
217 void DoSetProfileToneL( TInt aProfileId, |
|
218 TProfileTones aToneSetting, const TDesC& aFileName ); |
|
219 |
|
220 /** |
|
221 * Sets the tone to an MProfileExtended instance. |
|
222 * @param aProfile The MProfileExtended instance. |
|
223 * @param aToneSetting Identifies the tone which is updated. |
|
224 * @param aFileName The tone file name. |
|
225 */ |
|
226 void SetToneL( MProfileExtended& aProfile, |
|
227 TProfileTones aToneSetting, const TDesC& aFileName ); |
|
228 |
|
229 /** |
|
230 * Reads a tone setting from an MProfileExtended instance. |
|
231 * @param aProfile The MProfileExtended instance. |
|
232 * @param aToneSetting Identifies the tone which is read. |
|
233 * @return Returns the tone file name. |
|
234 */ |
|
235 const TDesC& ReadToneL( const MProfileExtended& aProfile, |
|
236 TProfileTones aToneSetting ) const; |
|
237 |
|
238 /** |
|
239 * Checks that the given tone file exists and that it is |
|
240 * a legal file to be used as a ringing or alert tone. |
|
241 * @since 2.6 |
|
242 * @param aFileName Full path and filename of the file to be checked. |
|
243 * @return KErrNone if the file can be used as a ringing or alert tone, |
|
244 * KErrNotFound if the file cannot be found, |
|
245 * KErrNotSupported if a file is of an unsupported type or |
|
246 * KErrPermissionDenied if the file is not allowed |
|
247 * to be used as a ringing or alert tone. |
|
248 * KErrGeneral if DRM rights are insufficient. |
|
249 * KErrArgument if the file is DRM protected |
|
250 * audio/mp4 and those are not allowed as ringingtones. |
|
251 */ |
|
252 TInt CheckFileL( const TDesC& aFileName ); |
|
253 |
|
254 /** |
|
255 * Checks if a DRM protected file can be used as a ringing or alert tone. |
|
256 * @since 2.6 |
|
257 * @param aFileName Full path and filename of the file to be checked. |
|
258 * @return KErrNone if the file can be used as a ringing or alert tone or |
|
259 * KErrGeneral if DRM rights are insufficient. |
|
260 */ |
|
261 TInt CheckProtectedFileL( const TDesC& aFileName ); |
|
262 |
|
263 /** |
|
264 * Tells whether a file can be registered as automated content or not. |
|
265 * If DRM is not supported, returns always EFalse. |
|
266 * @param aFileName File to be registered as automated content. |
|
267 * @return Returns ETrue if aFileName can be set as automated content. |
|
268 * Returns EFalse if can't or DRM is not supported. |
|
269 */ |
|
270 TBool CanSetAutomated( const TDesC& aFileName ); |
|
271 |
|
272 /** |
|
273 * Asks user if he/she wants to activate unactivated content. |
|
274 * Shows a query. Does nothing if DRM is not supported. |
|
275 * @param aFileName File to be registered as automated content. |
|
276 * @return Returns KErrCancel if user cancels the query. |
|
277 */ |
|
278 TInt AskAutomated( const TDesC& aFileName ); |
|
279 |
|
280 /** |
|
281 * Registers a file to automated content list without any queries. |
|
282 * Errors are omitted. Does nothing if DRM is not supported. |
|
283 * @param aToneSetting The type of tone (e.g. ringing tone, SMS tone) to |
|
284 * be registered as automated content. |
|
285 * @param aFileName File to be registered as automated content. |
|
286 * @return KErrNone or a system-wide error code. |
|
287 */ |
|
288 TInt SetAutomated( TProfileTones aToneSetting, const TDesC& aFileName ); |
|
289 |
|
290 /** |
|
291 * Removes a file from automated content list. |
|
292 * Errors are omitted. Does nothing if DRM is not supported. |
|
293 * @param aFileName File to be removed from automated content list. |
|
294 */ |
|
295 void RemoveAutomated( const TDesC& aFileName ); |
|
296 |
|
297 /** |
|
298 * Returns data type of a file. |
|
299 * @param aFileName Full path and filename. |
|
300 * @return Returns the data type of the file. |
|
301 */ |
|
302 TBuf<KMaxDataTypeLength> DataTypeL( const TDesC& aFileName ) const; |
|
303 |
|
304 /** |
|
305 * Returns whether a file is protected content or not. |
|
306 * Returns always EFalse if DRM is not supported. |
|
307 * @param aFileName The file name. |
|
308 * @return Returns whether the file is protected content or not. |
|
309 */ |
|
310 TBool IsProtected( const TDesC& aFileName ) const; |
|
311 |
|
312 /** |
|
313 * Returns whether a file is protected content or not. |
|
314 * Returns always EFalse if DRM is not supported. |
|
315 * @param aFileName The file name. |
|
316 * @return Returns whether the file is protected content or not. |
|
317 */ |
|
318 TBool IsProtectedL( const TDesC& aFileName ) const; |
|
319 |
|
320 /** |
|
321 * Displays an error note. |
|
322 * @param aResourceId Resource ID to a TBUF resource. |
|
323 */ |
|
324 void ShowErrorNoteL( TInt aResourceId ) const; |
|
325 |
|
326 /** |
|
327 * Returns info whether given filetype is allowed as ringingtone |
|
328 * @param aDataType Tone MIME type |
|
329 * @return ETrue if tone is allowed to be selected |
|
330 */ |
|
331 TBool AllowSelect( const TDesC& aDataType ) const; |
|
332 |
|
333 /** |
|
334 * Checks the result of CheckFileL() and leaves if needed. Also checks |
|
335 * if the file is protected and can be set as automated content. |
|
336 * @param aResult result of the CheckFileL() call made before this. |
|
337 * @param aFileName the name of the file to be checked for protection |
|
338 * and if it is settable as automated content. |
|
339 * @return KErrNone, if ok, otherwise a system-wide error code. |
|
340 */ |
|
341 TInt CheckResultAndProtectionL( TInt aResult, |
|
342 const TDesC& aFileName ); |
|
343 /** |
|
344 * Checks ringing tone file size. |
|
345 * @param aFile file to check. |
|
346 * @param aSizeLimitKB maximum allowed file size in KB. |
|
347 * @return KErrNone, if ok. |
|
348 * KErrTooBig, if configurable file size limit exceeded. |
|
349 */ |
|
350 TInt CheckToneFileSizeL( const TDesC& aFile, TInt aSizeLimitKB ); |
|
351 |
|
352 /** |
|
353 * Reads maximimum ringing tone file size in KB from cenrep. |
|
354 */ |
|
355 void GetMaxToneFileSizeL(); |
|
356 |
|
357 /** |
|
358 * Displays error note about exceeded tone file size. |
|
359 * @param aSizeLimitKB file size limit. |
|
360 */ |
|
361 void ShowSizeErrorNoteL( TInt aSizeLimitKB ); |
|
362 |
|
363 private: |
|
364 |
|
365 /// Default constructor |
|
366 CProfileToneHandler(); |
|
367 |
|
368 /// 2nd phase constructor |
|
369 void ConstructL(); |
|
370 |
|
371 /// Constructor for the DRM objects |
|
372 void DrmConstructL(); |
|
373 |
|
374 /// Destructor for the DRM objects |
|
375 void ReleaseDrm(); |
|
376 |
|
377 /// Functions related to WMDRM protection check |
|
378 TBool IsFileWMDRMProtectedL( const TDesC& aFileName ); |
|
379 |
|
380 /// Called by SetAutomated |
|
381 TInt SetAutomatedL( TProfileTones aToneSetting, const TDesC& aFileName ); |
|
382 |
|
383 private: // Data |
|
384 |
|
385 /// Owns: DRM Helper client. |
|
386 CDRMHelper* iDrmHelper; |
|
387 |
|
388 /// Owns: DRM Common client |
|
389 DRMCommon* iDrmCommon; |
|
390 |
|
391 /// Owns: Profile Engine Extended interface. |
|
392 MProfileEngineExtended* iProfileEngine; |
|
393 |
|
394 /// Owns: Profiles local features. |
|
395 MProfilesLocalFeatures* iProfilesFeatures; |
|
396 |
|
397 /// Supplementary services client for reading Alternate Line Service. |
|
398 RSSSettings iSSSettings; |
|
399 |
|
400 /// File Server client. |
|
401 RFs iFs; |
|
402 |
|
403 /// Alternate Line Setting value. |
|
404 TInt iAlternateLineSetting; |
|
405 |
|
406 /// Maximum allowed tone file size in kilo bytes. |
|
407 TInt iMaxSizeKB; |
|
408 |
|
409 }; |
|
410 |
|
411 #endif // CPROFILETONEHANDLER_H |
|
412 |
|
413 // End of File |
|