|
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 CProfileTonesImpl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CProfileTonesImpl.h" |
|
22 #include <s32strm.h> |
|
23 #include <centralrepository.h> |
|
24 #include "ProfileEngUtils.h" |
|
25 #include "ProfileEnginePrivateCRKeys.h" |
|
26 #include <hwrmvibrasdkcrkeys.h> |
|
27 |
|
28 #include <psmsettings.h> |
|
29 #include <psmsrvdomaincrkeys.h> |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CProfileTonesImpl::ConstructL |
|
35 // Symbian 2nd phase constructor can leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 void CProfileTonesImpl::ConstructL() |
|
39 { |
|
40 const TDesC& des = KNullDesC(); |
|
41 iRingingTone1 = des.AllocL(); |
|
42 iRingingTone2 = des.AllocL(); |
|
43 iMessageAlertTone = des.AllocL(); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CProfileTonesImpl::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CProfileTonesImpl::ConstructL( |
|
52 const MProfileTones& aProfileTones ) |
|
53 { |
|
54 iRingingTone1 = aProfileTones.RingingTone1().AllocL(); |
|
55 iRingingTone2 = aProfileTones.RingingTone1().AllocL(); |
|
56 iMessageAlertTone = aProfileTones.MessageAlertTone().AllocL(); |
|
57 iProfileToneSettings = aProfileTones.ToneSettings(); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CProfileTonesImpl::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CProfileTonesImpl* CProfileTonesImpl::NewL() |
|
66 { |
|
67 CProfileTonesImpl* self = new( ELeave ) CProfileTonesImpl; |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CProfileTonesImpl::NewL |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CProfileTonesImpl* CProfileTonesImpl::NewL( |
|
82 const MProfileTones& aProfileTones ) |
|
83 { |
|
84 CProfileTonesImpl* self = new( ELeave ) CProfileTonesImpl; |
|
85 |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL( aProfileTones ); |
|
88 CleanupStack::Pop(); |
|
89 |
|
90 return self; |
|
91 } |
|
92 |
|
93 // Destructor |
|
94 CProfileTonesImpl::~CProfileTonesImpl() |
|
95 { |
|
96 delete iRingingTone1; |
|
97 delete iRingingTone2; |
|
98 delete iMessageAlertTone; |
|
99 } |
|
100 |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CProfileTonesImpl::InternalizeL |
|
104 // |
|
105 // (other items were commented in a header). |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CProfileTonesImpl::InternalizeL( CRepository& aCenRep, TInt aProfileId ) |
|
109 { |
|
110 delete iRingingTone1; |
|
111 iRingingTone1 = NULL; |
|
112 delete iRingingTone2; |
|
113 iRingingTone2 = NULL; |
|
114 delete iMessageAlertTone; |
|
115 iMessageAlertTone = NULL; |
|
116 TFileName toneFile; |
|
117 |
|
118 // Ringing tone 1 |
|
119 User::LeaveIfError( |
|
120 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngRingingTone, |
|
121 aProfileId ), toneFile ) ); |
|
122 iRingingTone1 = toneFile.AllocL(); |
|
123 |
|
124 // Ringing tone 2 |
|
125 User::LeaveIfError( |
|
126 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngRingingTone2, |
|
127 aProfileId ), toneFile ) ); |
|
128 iRingingTone2 = toneFile.AllocL(); |
|
129 |
|
130 // Message alert tone |
|
131 User::LeaveIfError( |
|
132 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngMsgTone, |
|
133 aProfileId ), toneFile ) ); |
|
134 iMessageAlertTone = toneFile.AllocL(); |
|
135 |
|
136 // Settings |
|
137 TInt value( 0 ); |
|
138 User::LeaveIfError( |
|
139 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngRingingType, |
|
140 aProfileId ), value ) ); |
|
141 iProfileToneSettings.iRingingType = TProfileRingingType( value ); |
|
142 User::LeaveIfError( |
|
143 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngKeypadVolume, |
|
144 aProfileId ), value ) ); |
|
145 iProfileToneSettings.iKeypadVolume = TProfileKeypadVolume( value ); |
|
146 User::LeaveIfError( |
|
147 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngRingingVolume, |
|
148 aProfileId ), iProfileToneSettings.iRingingVolume ) ); |
|
149 User::LeaveIfError( |
|
150 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngVibra, |
|
151 aProfileId ), iProfileToneSettings.iVibratingAlert ) ); |
|
152 User::LeaveIfError( |
|
153 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngEmailVibra, |
|
154 aProfileId ), iProfileToneSettings.iEmailVibratingAlert ) ); |
|
155 User::LeaveIfError( |
|
156 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngWarnAndGameTones, |
|
157 aProfileId ), iProfileToneSettings.iWarningAndGameTones ) ); |
|
158 User::LeaveIfError( |
|
159 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngMediaVolume, |
|
160 aProfileId ), iProfileToneSettings.iMediaVolume ) ); |
|
161 User::LeaveIfError( |
|
162 aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngTextToSpeechTone, |
|
163 aProfileId ), iProfileToneSettings.iTextToSpeech ) ); |
|
164 |
|
165 InitPowerSaveMode(); |
|
166 |
|
167 if ( iPowerSaveMode ) |
|
168 { |
|
169 iProfileToneSettings.iVibratingAlert = iPsmConfigVibra; |
|
170 iProfileToneSettings.iEmailVibratingAlert = iPsmConfigVibra; |
|
171 iProfileToneSettings.iKeypadVolume = |
|
172 TProfileKeypadVolume( iPsmConfigKeypadVolume ); |
|
173 } |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CProfileTonesImpl::ExternalizeL |
|
178 // |
|
179 // (other items were commented in a header). |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CProfileTonesImpl::ExternalizeL( CRepository& aCenRep, TInt aProfileId ) const |
|
183 { |
|
184 // Ringing tone 1 |
|
185 User::LeaveIfError( |
|
186 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngRingingTone, |
|
187 aProfileId ), *iRingingTone1 ) ); |
|
188 |
|
189 // Ringing tone 2 |
|
190 User::LeaveIfError( |
|
191 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngRingingTone2, |
|
192 aProfileId ), *iRingingTone2 ) ); |
|
193 |
|
194 // Message alert tone |
|
195 User::LeaveIfError( |
|
196 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngMsgTone, |
|
197 aProfileId ), *iMessageAlertTone ) ); |
|
198 |
|
199 // Tone Settings |
|
200 User::LeaveIfError( |
|
201 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngRingingType, |
|
202 aProfileId ), iProfileToneSettings.iRingingType ) ); |
|
203 User::LeaveIfError( |
|
204 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngKeypadVolume, |
|
205 aProfileId ), iProfileToneSettings.iKeypadVolume ) ); |
|
206 User::LeaveIfError( |
|
207 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngRingingVolume, |
|
208 aProfileId ), iProfileToneSettings.iRingingVolume ) ); |
|
209 |
|
210 if ( !ProfileEngUtils::PowerSaveMode() ) |
|
211 { |
|
212 User::LeaveIfError( |
|
213 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngKeypadVolume, |
|
214 aProfileId ), iProfileToneSettings.iKeypadVolume ) ); |
|
215 User::LeaveIfError( |
|
216 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngVibra, |
|
217 aProfileId ), iProfileToneSettings.iVibratingAlert ) ); |
|
218 |
|
219 User::LeaveIfError( |
|
220 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngEmailVibra, |
|
221 aProfileId ), iProfileToneSettings.iEmailVibratingAlert ) ); |
|
222 } |
|
223 User::LeaveIfError( |
|
224 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngWarnAndGameTones, |
|
225 aProfileId ), iProfileToneSettings.iWarningAndGameTones ) ); |
|
226 User::LeaveIfError( |
|
227 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngMediaVolume, |
|
228 aProfileId ), iProfileToneSettings.iMediaVolume ) ); |
|
229 User::LeaveIfError( |
|
230 aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngTextToSpeechTone, |
|
231 aProfileId ), iProfileToneSettings.iTextToSpeech ) ); |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CProfileTonesImpl::SetRingingTone2L |
|
236 // |
|
237 // (other items were commented in a header). |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CProfileTonesImpl::SetRingingTone2L( |
|
241 const TDesC& aRingingTone ) |
|
242 { |
|
243 HBufC* tmp = aRingingTone.Left( KMaxFileName ).AllocL(); |
|
244 delete iRingingTone2; |
|
245 iRingingTone2 = tmp; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CProfileTonesImpl::SetRingingTone1L |
|
250 // |
|
251 // (other items were commented in a header). |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 void CProfileTonesImpl::SetRingingTone1L( |
|
255 const TDesC& aRingingTone ) |
|
256 { |
|
257 HBufC* tmp = aRingingTone.Left( KMaxFileName ).AllocL(); |
|
258 delete iRingingTone1; |
|
259 iRingingTone1 = tmp; |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CProfileTonesImpl::MessageAlertTone |
|
264 // |
|
265 // (other items were commented in a header). |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 const TDesC& CProfileTonesImpl::MessageAlertTone() const |
|
269 { |
|
270 return *iMessageAlertTone; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CProfileTonesImpl::RingingTone1 |
|
275 // |
|
276 // (other items were commented in a header). |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 const TDesC& CProfileTonesImpl::RingingTone1() const |
|
280 { |
|
281 return *iRingingTone1; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CProfileTonesImpl::RingingTone2 |
|
286 // |
|
287 // (other items were commented in a header). |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 const TDesC& CProfileTonesImpl::RingingTone2() const |
|
291 { |
|
292 return *iRingingTone2; |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CProfileTonesImpl::SetMessageAlertToneL |
|
297 // |
|
298 // (other items were commented in a header). |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 void CProfileTonesImpl::SetMessageAlertToneL( |
|
302 const TDesC& aMessageAlertTone ) |
|
303 { |
|
304 HBufC* tmp = aMessageAlertTone.Left( KMaxFileName ).AllocL(); |
|
305 delete iMessageAlertTone; |
|
306 iMessageAlertTone = tmp; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CProfileTonesImpl::ToneSettings |
|
311 // |
|
312 // (other items were commented in a header). |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 const TProfileToneSettings& CProfileTonesImpl::ToneSettings() const |
|
316 { |
|
317 return iProfileToneSettings; |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CProfileTonesImpl::SetToneSettings |
|
322 // |
|
323 // (other items were commented in a header). |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 TProfileToneSettings& CProfileTonesImpl::SetToneSettings() |
|
327 { |
|
328 return iProfileToneSettings; |
|
329 } |
|
330 |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CProfileTonesImpl::InitPowerSaveMode |
|
334 // |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 void CProfileTonesImpl::InitPowerSaveMode() |
|
338 { |
|
339 const TInt KVibraOff = 0; |
|
340 const TInt KMinVolume = 0; |
|
341 |
|
342 iPsmConfigVibra = KVibraOff; |
|
343 iPsmConfigKeypadVolume = KMinVolume; |
|
344 |
|
345 iPowerSaveMode = ProfileEngUtils::PowerSaveMode(); |
|
346 |
|
347 if ( iPowerSaveMode ) |
|
348 { |
|
349 TRAP_IGNORE( ReadPowerSaveConfigL() ); |
|
350 } |
|
351 } |
|
352 |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CProfileTonesImpl::ReadPowerSaveConfigL |
|
356 // |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 void CProfileTonesImpl::ReadPowerSaveConfigL() |
|
360 { |
|
361 |
|
362 // |
|
363 // Read psm specific vibra and keypad volume from profiles public cenrep. |
|
364 // Psm plugin updates those when psm mode changes. |
|
365 // |
|
366 |
|
367 CRepository* cenrep = CRepository::NewLC( KCRUidVibraCtrl ); |
|
368 User::LeaveIfError( cenrep->Get( KVibraCtrlProfileVibraEnabled, iPsmConfigVibra ) ); |
|
369 CleanupStack::PopAndDestroy( cenrep ); |
|
370 |
|
371 cenrep = CRepository::NewLC( KCRUidProfileEngine ); |
|
372 User::LeaveIfError( cenrep->Get( KProEngActiveKeypadVolume, iPsmConfigKeypadVolume ) ); |
|
373 CleanupStack::PopAndDestroy( cenrep ); |
|
374 } |
|
375 |
|
376 // End of File |