|
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: Implementation of CProEngTonesImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CProEngTonesImpl.h" |
|
22 #include <MProfileTones.h> |
|
23 #include <MProfileExtraTones.h> |
|
24 #include "MProfileSetTones.h" |
|
25 #include "MProfileSetExtraTones.h" |
|
26 #include "MProfileExtended.h" |
|
27 #include "CProEngToneHandler.h" |
|
28 #include "ProfileEng.hrh" // TProfileSettingId |
|
29 #include <pathinfo.h> |
|
30 #include <ProfileEngineDomainConstants.h> |
|
31 |
|
32 namespace |
|
33 { |
|
34 // CONSTANTS |
|
35 // This flag is only used internally by this class (actually 0x0002 is |
|
36 // defined in MProfileExtended.h as EProfileFlagRingingType) for indicating |
|
37 // whether ringing tone 2 has been modified or not: |
|
38 const TInt KProEngFlagRingingTone2 = 0x0002; |
|
39 } |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CProEngTonesImpl::CProEngTonesImpl |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CProEngTonesImpl::CProEngTonesImpl( |
|
48 const MProfileTones& aProfileTones, |
|
49 MProfileSetTones& aProfileSetTones, |
|
50 const MProfileExtraTones& aProfileExtraTones, |
|
51 MProfileSetExtraTones& aProfileSetExtraTones, |
|
52 TUint32 aModifiableFlags ) |
|
53 : iProfileTones( aProfileTones ), iProfileSetTones( aProfileSetTones ), |
|
54 iProfileExtraTones( aProfileExtraTones ), |
|
55 iProfileSetExtraTones( aProfileSetExtraTones ), |
|
56 iModifiableFlags( aModifiableFlags ), |
|
57 iNullTone( KNullDesC ) |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CProEngTonesImpl::ConstructL |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CProEngTonesImpl::ConstructL() |
|
66 { |
|
67 // Read the file to be used when KNullDesC is set as an alert tone: |
|
68 RBuf toneBuf; |
|
69 toneBuf.CreateL( KMaxFileName ); |
|
70 CleanupClosePushL( toneBuf ); |
|
71 toneBuf.Copy( TParsePtrC( PathInfo::RomRootPath() ).Drive() ); |
|
72 toneBuf.Append( KProfileNoSoundPath ); |
|
73 |
|
74 iEmptyTone = toneBuf.AllocL(); |
|
75 CleanupStack::PopAndDestroy(); // toneBuf |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CProEngTonesImpl::NewL |
|
80 // Two-phased constructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CProEngTonesImpl* CProEngTonesImpl::NewL( |
|
84 const MProfileTones& aProfileTones, |
|
85 MProfileSetTones& aProfileSetTones, |
|
86 const MProfileExtraTones& aProfileExtraTones, |
|
87 MProfileSetExtraTones& aProfileSetExtraTones, |
|
88 TUint32 aModifiableFlags ) |
|
89 { |
|
90 CProEngTonesImpl* self = new ( ELeave ) CProEngTonesImpl( |
|
91 aProfileTones, aProfileSetTones, aProfileExtraTones, |
|
92 aProfileSetExtraTones, aModifiableFlags ); |
|
93 |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 return self; |
|
99 } |
|
100 |
|
101 // Destructor |
|
102 CProEngTonesImpl::~CProEngTonesImpl() |
|
103 { |
|
104 delete iEmptyTone; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CProEngTonesImpl::RingingTone1 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 const TDesC& CProEngTonesImpl::RingingTone1() const |
|
112 { |
|
113 return iProfileTones.RingingTone1(); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CProEngTonesImpl::RingingTone2 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 const TDesC& CProEngTonesImpl::RingingTone2() const |
|
121 { |
|
122 return iProfileTones.RingingTone2(); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CProEngTonesImpl::MessageAlertTone |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 const TDesC& CProEngTonesImpl::MessageAlertTone() const |
|
130 { |
|
131 return iProfileTones.MessageAlertTone(); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CProEngTonesImpl::EmailAlertTone |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 const TDesC& CProEngTonesImpl::EmailAlertTone() const |
|
139 { |
|
140 return iProfileExtraTones.EmailAlertTone(); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CProEngTonesImpl::VideoCallRingingTone |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 const TDesC& CProEngTonesImpl::VideoCallRingingTone() const |
|
148 { |
|
149 return iProfileExtraTones.VideoCallRingingTone(); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CProEngTonesImpl::SetRingingTone1L |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CProEngTonesImpl::SetRingingTone1L( const TDesC& aRingingTone ) |
|
157 { |
|
158 if( iModifiableFlags & EProfileFlagRingingTone ) |
|
159 { |
|
160 TPtrC tonePtr( ConvertKNullToEmptyTone( aRingingTone ) ); |
|
161 iProfileSetTones.SetRingingTone1L( tonePtr ); |
|
162 iModifiedFlags |= EProfileFlagRingingTone; |
|
163 return KErrNone; |
|
164 } |
|
165 return KErrAccessDenied; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CProEngTonesImpl::SetRingingTone2L |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 TInt CProEngTonesImpl::SetRingingTone2L( const TDesC& aRingingTone ) |
|
173 { |
|
174 if( iModifiableFlags & EProfileFlagRingingTone ) |
|
175 { |
|
176 TPtrC tonePtr( ConvertKNullToEmptyTone( aRingingTone ) ); |
|
177 iProfileSetTones.SetRingingTone2L( tonePtr ); |
|
178 iModifiedFlags |= KProEngFlagRingingTone2; |
|
179 return KErrNone; |
|
180 } |
|
181 return KErrAccessDenied; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CProEngTonesImpl::SetMessageAlertToneL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 TInt CProEngTonesImpl::SetMessageAlertToneL( const TDesC& aMessageAlertTone ) |
|
189 { |
|
190 if( iModifiableFlags & EProfileFlagMessageAlertTone ) |
|
191 { |
|
192 TPtrC tonePtr( ConvertKNullToEmptyTone( aMessageAlertTone ) ); |
|
193 iProfileSetTones.SetMessageAlertToneL( tonePtr ); |
|
194 iModifiedFlags |= EProfileFlagMessageAlertTone; |
|
195 return KErrNone; |
|
196 } |
|
197 return KErrAccessDenied; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CProEngTonesImpl::SetEmailAlertToneL |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 TInt CProEngTonesImpl::SetEmailAlertToneL( const TDesC& aEmailAlertTone ) |
|
205 { |
|
206 if( iModifiableFlags & EProfileFlagEmailAlertTone ) |
|
207 { |
|
208 TPtrC tonePtr( ConvertKNullToEmptyTone( aEmailAlertTone ) ); |
|
209 iProfileSetExtraTones.SetEmailAlertToneL( tonePtr ); |
|
210 iModifiedFlags |= EProfileFlagEmailAlertTone; |
|
211 return KErrNone; |
|
212 } |
|
213 return KErrAccessDenied; |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CProEngTonesImpl::SetVideoCallRingingToneL |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 TInt CProEngTonesImpl::SetVideoCallRingingToneL( const TDesC& aRingingTone ) |
|
221 { |
|
222 if( iModifiableFlags & EProfileFlagVideoCallRingingTone ) |
|
223 { |
|
224 TPtrC tonePtr( ConvertKNullToEmptyTone( aRingingTone ) ); |
|
225 iProfileSetExtraTones.SetVideoCallRingingToneL( tonePtr ); |
|
226 iModifiedFlags |= EProfileFlagVideoCallRingingTone; |
|
227 return KErrNone; |
|
228 } |
|
229 return KErrAccessDenied; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CProEngTonesImpl::CheckTonesL |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 TInt CProEngTonesImpl::CheckTonesL( CProEngToneHandler& aToneHandler ) |
|
237 { |
|
238 TInt result( KErrNone ); |
|
239 if( iModifiedFlags & EProfileFlagRingingTone ) |
|
240 { |
|
241 result = aToneHandler.CheckToneFileL( iProfileTones.RingingTone1(), |
|
242 EProfileSettingIdRingingTone ); |
|
243 if( result != KErrNone ) |
|
244 { |
|
245 return result; |
|
246 } |
|
247 } |
|
248 if( iModifiedFlags & KProEngFlagRingingTone2 ) |
|
249 { |
|
250 result = aToneHandler.CheckToneFileL( iProfileTones.RingingTone2(), |
|
251 EProfileSettingIdRingingTone2 ); |
|
252 if( result != KErrNone ) |
|
253 { |
|
254 return result; |
|
255 } |
|
256 } |
|
257 if( iModifiedFlags & EProfileFlagMessageAlertTone ) |
|
258 { |
|
259 result = aToneHandler.CheckToneFileL( |
|
260 iProfileTones.MessageAlertTone(), |
|
261 EProfileSettingIdMsgTone ); |
|
262 if( result != KErrNone ) |
|
263 { |
|
264 return result; |
|
265 } |
|
266 } |
|
267 if( iModifiedFlags & EProfileFlagEmailAlertTone ) |
|
268 { |
|
269 result = aToneHandler.CheckToneFileL( |
|
270 iProfileExtraTones.EmailAlertTone(), |
|
271 EProfileSettingIdEmailTone ); |
|
272 if( result != KErrNone ) |
|
273 { |
|
274 return result; |
|
275 } |
|
276 } |
|
277 if( iModifiedFlags & EProfileFlagVideoCallRingingTone ) |
|
278 { |
|
279 result = aToneHandler.CheckToneFileL( |
|
280 iProfileExtraTones.VideoCallRingingTone(), |
|
281 EProfileSettingIdVideoCallTone ); |
|
282 } |
|
283 return result; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CProEngTonesImpl::HandleAutomatedContentL |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 TInt CProEngTonesImpl::HandleAutomatedContent( |
|
291 CProEngToneHandler& aToneHandler, const CProEngTonesImpl& aOldTones ) |
|
292 { |
|
293 TInt err( KErrNone ); |
|
294 if( iModifiedFlags & EProfileFlagRingingTone ) |
|
295 { |
|
296 err = aToneHandler.HandleAutomatedContent( |
|
297 EProfileSettingIdRingingTone, |
|
298 iProfileTones.RingingTone1(), |
|
299 aOldTones.iProfileTones.RingingTone1() ); |
|
300 iModifiedFlags &= ~EProfileFlagRingingTone; |
|
301 } |
|
302 if( !err && ( iModifiedFlags & KProEngFlagRingingTone2 ) ) |
|
303 { |
|
304 err = aToneHandler.HandleAutomatedContent( |
|
305 EProfileSettingIdRingingTone2, |
|
306 iProfileTones.RingingTone2(), |
|
307 aOldTones.iProfileTones.RingingTone2() ); |
|
308 iModifiedFlags &= ~KProEngFlagRingingTone2; |
|
309 } |
|
310 if( !err && ( iModifiedFlags & EProfileFlagMessageAlertTone ) ) |
|
311 { |
|
312 err = aToneHandler.HandleAutomatedContent( |
|
313 EProfileSettingIdMsgTone, |
|
314 iProfileTones.MessageAlertTone(), |
|
315 aOldTones.iProfileTones.MessageAlertTone() ); |
|
316 iModifiedFlags &= ~EProfileFlagMessageAlertTone; |
|
317 } |
|
318 if( !err && ( iModifiedFlags & EProfileFlagEmailAlertTone ) ) |
|
319 { |
|
320 err = aToneHandler.HandleAutomatedContent( |
|
321 EProfileSettingIdEmailTone, |
|
322 iProfileExtraTones.EmailAlertTone(), |
|
323 aOldTones.iProfileExtraTones.EmailAlertTone() ); |
|
324 iModifiedFlags &= ~EProfileFlagEmailAlertTone; |
|
325 } |
|
326 if( !err && ( iModifiedFlags & EProfileFlagVideoCallRingingTone ) ) |
|
327 { |
|
328 err = aToneHandler.HandleAutomatedContent( |
|
329 EProfileSettingIdVideoCallTone, |
|
330 iProfileExtraTones.VideoCallRingingTone(), |
|
331 aOldTones.iProfileExtraTones.VideoCallRingingTone() ); |
|
332 iModifiedFlags &= ~EProfileFlagVideoCallRingingTone; |
|
333 } |
|
334 return err; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CProEngTonesImpl::ConvertKNullToEmptyTone |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 const TDesC& CProEngTonesImpl::ConvertKNullToEmptyTone( |
|
342 const TDesC& aTone ) const |
|
343 { |
|
344 if( aTone.Length() == 0 ) |
|
345 { |
|
346 return *iEmptyTone; |
|
347 } |
|
348 return aTone; |
|
349 } |
|
350 |
|
351 // End of File |
|
352 |
|
353 |