|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cpprofilemodel_p.h" |
|
19 #include "cpprofilemodel.h" |
|
20 #include <cplogger.h> |
|
21 #include <e32base.h> |
|
22 #include <QString> |
|
23 #include <QMap> |
|
24 #include <MProfileEngineExtended2.h> |
|
25 #include <MProfileExtended.h> |
|
26 #include <MProfileName.h> |
|
27 #include <MProfileTones.h> |
|
28 #include <MProfileSetTones.h> |
|
29 #include <MProfileExtraTones.h> |
|
30 #include <MProfileSetExtraTones.h> |
|
31 #include <MProfileExtraSettings.h> |
|
32 #include <MProfileSetExtraSettings.h> |
|
33 #include <MProfileFeedbackSettings.h> |
|
34 #include <MProfileSetFeedbackSettings.h> |
|
35 #include <MProfilesNamesArray.h> |
|
36 #include <settingsinternalcrkeys.h> |
|
37 #include <hbglobal.h> |
|
38 #include <QtCore/QStringList> |
|
39 #include <MProfileExtended2.h> |
|
40 #include <MProfileSetExtraTones2.h> |
|
41 #include <MProfileExtraTones2.h> |
|
42 #include <MProfileVibraSettings.h> |
|
43 #include <MProfileSetVibraSettings.h> |
|
44 #include <TProfileToneSettings.h> |
|
45 #include <hwrmvibrasdkcrkeys.h> |
|
46 #include <centralrepository.h> |
|
47 #include <XQConversions> |
|
48 #include <profile.hrh> |
|
49 /* |
|
50 * Constructor |
|
51 */ |
|
52 CpProfileModelPrivate::CpProfileModelPrivate() |
|
53 : mEngine(0), |
|
54 mProfileNames(0), |
|
55 q_ptr(0) |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 /* |
|
61 * Initialize the profile engine and available profile list for profile wrapper. |
|
62 */ |
|
63 void CpProfileModelPrivate::initialize(CpProfileModel *parent) |
|
64 { |
|
65 q_ptr = parent; |
|
66 CPFW_LOG("CpProfileModelPrivate::CpProfileModelPrivate(), START."); |
|
67 TRAP_IGNORE( |
|
68 mEngine = CreateProfileEngineExtended2L(); |
|
69 mProfileNames = mEngine->ProfilesNamesArrayLC(); |
|
70 CleanupStack::Pop(); // pop the pointer of mProfileNames |
|
71 /* |
|
72 * Currently, engine part will return all previous version of profile |
|
73 * so some invalid profile will be added in the new list, to avoid this |
|
74 * use hard code to get the right list of profile. |
|
75 */ |
|
76 /*MProfilesNamesArray* nameList = mEngine->ProfilesNamesArrayLC(); |
|
77 int profileCount = nameList->MdcaCount(); |
|
78 for (int i = 0; i<profileCount; i++) { |
|
79 MProfileName *profileName = nameList->ProfileName(i); |
|
80 mProfileList.insert(profileName->Id(), mEngine->Profile2L(profileName->Id())); |
|
81 } |
|
82 CleanupStack::PopAndDestroy(*nameList);*/ |
|
83 ); |
|
84 mProfileList.append(static_cast<int>(EProfileWrapperGeneralId)); // general id |
|
85 mProfileList.append(static_cast<int>(EProfileWrapperMeetingId)); // meeting id |
|
86 CPFW_LOG("CpProfileModelPrivate::CpProfileModelPrivate(), END"); |
|
87 } |
|
88 |
|
89 /* |
|
90 * Destructor |
|
91 */ |
|
92 CpProfileModelPrivate::~CpProfileModelPrivate() |
|
93 { |
|
94 if (mEngine!=0) { |
|
95 mEngine->Release(); |
|
96 } |
|
97 if (mProfileNames) { |
|
98 delete mProfileNames; |
|
99 } |
|
100 mProfileList.clear(); |
|
101 } |
|
102 |
|
103 /* |
|
104 * Get profile name with its id |
|
105 */ |
|
106 QString CpProfileModelPrivate::profileName(int profileId) const |
|
107 { |
|
108 CPFW_LOG("CpProfileModelPrivate::profileName(), START."); |
|
109 // Return an empty string if id is not valid. |
|
110 if (!isValidProfile(profileId)) { |
|
111 return QString(); |
|
112 } |
|
113 |
|
114 const MProfileName* name = mProfileNames->ProfileName(profileId); |
|
115 QString profileName; |
|
116 if (name != 0) { |
|
117 profileName = XQConversions::s60DescToQString(name->Name()); |
|
118 } |
|
119 CPFW_LOG("CpProfileModelPrivate::profileName(), END."); |
|
120 return profileName; |
|
121 } |
|
122 |
|
123 /* |
|
124 * Get available profiles' name list. |
|
125 */ |
|
126 QStringList CpProfileModelPrivate::profileNames() const |
|
127 { |
|
128 CPFW_LOG("CpProfileModelPrivate::profileNames(), START."); |
|
129 QStringList nameList; |
|
130 |
|
131 foreach(int profileId, mProfileList) { |
|
132 const MProfileName *name = mProfileNames->ProfileName(profileId); |
|
133 if (name != 0) { |
|
134 nameList.append(XQConversions::s60DescToQString(name->Name())); |
|
135 } |
|
136 } |
|
137 |
|
138 CPFW_LOG("CpProfileModelPrivate::profileNames(), END."); |
|
139 return nameList; |
|
140 } |
|
141 |
|
142 |
|
143 /* |
|
144 * Activate a profile with its id, return the result. |
|
145 */ |
|
146 int CpProfileModelPrivate::activateProfile(int profileId) |
|
147 { |
|
148 CPFW_LOG("CpProfileModelPrivate::activateProfile(), START."); |
|
149 // currently, only two profile remains: general and meeting, |
|
150 // But profile engine also support the old profile like: |
|
151 // silence, out ... |
|
152 // so filter the invalid profile id first. |
|
153 if (!isValidProfile(profileId)) { |
|
154 return KErrNotFound; |
|
155 } |
|
156 TRAPD( err, |
|
157 mEngine->SetActiveProfileL( profileId ); |
|
158 ); |
|
159 CPFW_LOG("CpProfileModelPrivate::activateProfile(), END."); |
|
160 return err; |
|
161 } |
|
162 |
|
163 /* |
|
164 * Get active profile's id |
|
165 */ |
|
166 int CpProfileModelPrivate::activeProfileId() const |
|
167 { |
|
168 return mEngine->ActiveProfileId(); |
|
169 } |
|
170 |
|
171 /* |
|
172 * Return all profile settings according to profile's id |
|
173 */ |
|
174 void CpProfileModelPrivate::profileSettings(int profileId, |
|
175 CpProfileSettings& profileSettings) |
|
176 { |
|
177 if (!isValidProfile(profileId)) { |
|
178 return; |
|
179 } |
|
180 QT_TRAP_THROWING( |
|
181 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
182 CleanupStack::PushL(profileExtend); |
|
183 |
|
184 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
185 const TProfileToneSettings &toneSettings = setTones.ToneSettings(); |
|
186 const MProfileExtraTones2 &extTones = profileExtend->ProfileExtraTones2(); |
|
187 const MProfileVibraSettings &vibraSettings = |
|
188 profileExtend->ProfileVibraSettings(); |
|
189 const MProfileExtraSettings &extraSettings = |
|
190 profileExtend->ProfileExtraSettings(); |
|
191 const MProfileFeedbackSettings &feedbackSettings = |
|
192 extraSettings.ProfileFeedbackSettings(); |
|
193 |
|
194 profileSettings.mRingTone = XQConversions::s60DescToQString(setTones.RingingTone1()); |
|
195 profileSettings.mMessageTone = XQConversions::s60DescToQString(setTones.MessageAlertTone()); |
|
196 profileSettings.mEmailTone = XQConversions::s60DescToQString(extTones.EmailAlertTone()); |
|
197 profileSettings.mReminderTone = XQConversions::s60DescToQString(extTones.ReminderTone()); |
|
198 profileSettings.mNotificationTone = toneSettings.iWarningAndGameTones; |
|
199 |
|
200 // only use Keypad Volume as a base value for display in key & touch screen setting option |
|
201 profileSettings.mKeyTouchScreenTone = toneSettings.iKeypadVolume; |
|
202 profileSettings.mKeyTouchScreenVibra = feedbackSettings.TactileFeedback(); |
|
203 CleanupStack::Pop(); // profileExtend |
|
204 profileExtend->Release(); |
|
205 ); |
|
206 } |
|
207 /* |
|
208 * set profile settings |
|
209 */ |
|
210 void CpProfileModelPrivate::setProfileSettings(int profileId, CpProfileSettings& profileSettings) |
|
211 { |
|
212 if (!isValidProfile(profileId)) { |
|
213 return; |
|
214 } |
|
215 |
|
216 QT_TRAP_THROWING ( |
|
217 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
218 CleanupStack::PushL(profileExtend); |
|
219 |
|
220 MProfileSetTones &setTones = profileExtend->ProfileSetTones(); |
|
221 TProfileToneSettings &toneSettings = setTones.SetToneSettings(); |
|
222 MProfileSetExtraTones2 &setExtTones = |
|
223 profileExtend->ProfileSetExtraTones2(); |
|
224 MProfileSetVibraSettings &setVibraSettings = |
|
225 profileExtend->ProfileSetVibraSettings(); |
|
226 MProfileSetExtraSettings &extraSettings = |
|
227 profileExtend->ProfileSetExtraSettings(); |
|
228 MProfileSetFeedbackSettings &setFeedbackSettings = |
|
229 extraSettings.ProfileSetFeedbackSettings(); |
|
230 |
|
231 |
|
232 setTones.SetRingingTone1L(*XQConversions::qStringToS60Desc( |
|
233 profileSettings.mRingTone)); |
|
234 setTones.SetMessageAlertToneL(*XQConversions::qStringToS60Desc( |
|
235 profileSettings.mMessageTone)); |
|
236 setExtTones.SetEmailAlertToneL(*XQConversions::qStringToS60Desc( |
|
237 profileSettings.mEmailTone)); |
|
238 setExtTones.SetReminderToneL(*XQConversions::qStringToS60Desc( |
|
239 profileSettings.mReminderTone)); |
|
240 |
|
241 toneSettings.iWarningAndGameTones |
|
242 = profileSettings.mNotificationTone; |
|
243 // Change the keypad volume and touch screen tone together |
|
244 toneSettings.iKeypadVolume |
|
245 = static_cast<TProfileKeypadVolume> (profileSettings.mKeyTouchScreenTone); |
|
246 setFeedbackSettings.SetAudioFeedback( |
|
247 static_cast<TProfileAudioFeedback> (profileSettings.mKeyTouchScreenTone)); |
|
248 setFeedbackSettings.SetTactileFeedback( |
|
249 static_cast<TProfileTactileFeedback> (profileSettings.mKeyTouchScreenVibra)); |
|
250 |
|
251 mEngine->CommitChangeL(*profileExtend); |
|
252 CleanupStack::Pop(); // profileExtend |
|
253 ) |
|
254 } |
|
255 |
|
256 /* |
|
257 * Get the active profile's ring tone name |
|
258 */ |
|
259 QString CpProfileModelPrivate::ringTone() const |
|
260 { |
|
261 // return empty string when active profile id is invalid, |
|
262 // some old application still set the profile which is not available now, |
|
263 // this check can be removed when every application use a correct profile id |
|
264 |
|
265 QString ringTone; |
|
266 if (!isValidProfile(activeProfileId())) { |
|
267 return ringTone; |
|
268 } |
|
269 QT_TRAP_THROWING( |
|
270 MProfileExtended2 *profileExtend = mEngine->Profile2L(activeProfileId()); |
|
271 CleanupStack::PushL(profileExtend); |
|
272 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
273 |
|
274 ringTone = XQConversions::s60DescToQString(setTones.RingingTone1()); |
|
275 CleanupStack::Pop(); // profileExtend |
|
276 profileExtend->Release(); |
|
277 ) |
|
278 |
|
279 return ringTone; |
|
280 } |
|
281 |
|
282 /* |
|
283 * Set the ring tone for all profiles |
|
284 */ |
|
285 void CpProfileModelPrivate::setRingTone(const QString& filePath) |
|
286 { |
|
287 for (TInt i = 0; i < mProfileList.count(); ++i) { |
|
288 QT_TRAP_THROWING( |
|
289 MProfileExtended2 *profileExtend = mEngine->Profile2L(mProfileList.at(i)); |
|
290 CleanupStack::PushL(profileExtend); |
|
291 |
|
292 MProfileSetTones &setTones = profileExtend->ProfileSetTones(); |
|
293 |
|
294 setTones.SetRingingTone1L( *XQConversions::qStringToS60Desc(filePath) ); |
|
295 mEngine ->CommitChangeL(*profileExtend); |
|
296 CleanupStack::Pop(); // profileExtend |
|
297 profileExtend->Release(); |
|
298 ) |
|
299 } |
|
300 } |
|
301 |
|
302 /* |
|
303 * Get the ringing volume value |
|
304 */ |
|
305 int CpProfileModelPrivate::masterVolume() const |
|
306 { |
|
307 int masterVolume = 0; |
|
308 QT_TRAP_THROWING(masterVolume = mEngine->MasterVolumeL();) |
|
309 return masterVolume; |
|
310 } |
|
311 |
|
312 /* |
|
313 * Set the ringing volume |
|
314 */ |
|
315 void CpProfileModelPrivate::setMasterVolume(int volume) |
|
316 { |
|
317 // the volume range 1-10 |
|
318 if (volume >= EProfileRingingVolumeLevel1 && volume <= EProfileRingingVolumeLevel10) { |
|
319 QT_TRAP_THROWING(mEngine->SetMasterVolumeL( volume );) |
|
320 } |
|
321 } |
|
322 /* |
|
323 * Get the master vibra's status |
|
324 */ |
|
325 bool CpProfileModelPrivate::masterVibra() const |
|
326 { |
|
327 bool masterVibra = false; |
|
328 QT_TRAP_THROWING(masterVibra = mEngine->MasterVibraL();) |
|
329 return masterVibra; |
|
330 } |
|
331 |
|
332 /* |
|
333 * Set master vibra's status |
|
334 */ |
|
335 void CpProfileModelPrivate::setMasterVibra(bool isVibra) |
|
336 { |
|
337 QT_TRAP_THROWING(mEngine->SetMasterVibraL( isVibra );) |
|
338 } |
|
339 |
|
340 /* |
|
341 * Get the status of silence mode. |
|
342 */ |
|
343 bool CpProfileModelPrivate::silenceMode() const |
|
344 { |
|
345 bool isSlience = false; |
|
346 QT_TRAP_THROWING(isSlience = mEngine->SilenceModeL();) |
|
347 return isSlience; |
|
348 } |
|
349 |
|
350 /* |
|
351 * Set the status of silence mode |
|
352 */ |
|
353 void CpProfileModelPrivate::setSilenceMode(bool isSilence) |
|
354 { |
|
355 QT_TRAP_THROWING(mEngine->SetSilenceModeL( isSilence );) |
|
356 } |
|
357 |
|
358 /* |
|
359 * Return the ring tone of a profile, if the profile id is invalid, always |
|
360 * return an empty string |
|
361 */ |
|
362 QString CpProfileModelPrivate::ringTone(int profileId) const |
|
363 { |
|
364 QString ringTone; |
|
365 if(!isValidProfile(profileId)) { |
|
366 return ringTone; |
|
367 } |
|
368 QT_TRAP_THROWING( |
|
369 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
370 CleanupStack::PushL(profileExtend); |
|
371 |
|
372 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
373 |
|
374 ringTone = XQConversions::s60DescToQString(setTones.RingingTone1()); |
|
375 CleanupStack::Pop(); // profileExtend |
|
376 profileExtend->Release(); |
|
377 ) |
|
378 return ringTone; |
|
379 } |
|
380 |
|
381 /* |
|
382 * Set the ring tone for a profile, if the profile id is invalid, nothing happens |
|
383 */ |
|
384 void CpProfileModelPrivate::setRingTone(int profileId, const QString& filePath) |
|
385 { |
|
386 if(!isValidProfile(profileId)) { |
|
387 return; |
|
388 } |
|
389 QT_TRAP_THROWING( |
|
390 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
391 CleanupStack::PushL(profileExtend); |
|
392 |
|
393 MProfileSetTones &setTones = profileExtend->ProfileSetTones(); |
|
394 |
|
395 setTones.SetRingingTone1L(*XQConversions::qStringToS60Desc(filePath)); |
|
396 mEngine->CommitChangeL(*profileExtend); |
|
397 CleanupStack::Pop(); // profileExtend |
|
398 profileExtend->Release(); |
|
399 ) |
|
400 } |
|
401 |
|
402 /* |
|
403 * Get the message tone of a profile, if the profile id is invalid, always return |
|
404 * an empty string |
|
405 */ |
|
406 QString CpProfileModelPrivate::messageTone(int profileId) const |
|
407 { |
|
408 QString messageTone; |
|
409 if(!isValidProfile(profileId)) { |
|
410 return messageTone; |
|
411 } |
|
412 QT_TRAP_THROWING( |
|
413 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
414 CleanupStack::PushL(profileExtend); |
|
415 |
|
416 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
417 |
|
418 messageTone = XQConversions::s60DescToQString(setTones.MessageAlertTone()); |
|
419 CleanupStack::Pop(); // profileExtend |
|
420 profileExtend->Release(); |
|
421 ) |
|
422 |
|
423 return messageTone; |
|
424 } |
|
425 |
|
426 /* |
|
427 * Set the message tone of a profile, if the profile id is invalid, nothing happens |
|
428 */ |
|
429 void CpProfileModelPrivate::setMessageTone(int profileId, const QString& filePath) |
|
430 { |
|
431 if(!isValidProfile(profileId)) { |
|
432 return; |
|
433 } |
|
434 QT_TRAP_THROWING( |
|
435 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
436 CleanupStack::PushL(profileExtend); |
|
437 MProfileSetTones &setTones = |
|
438 profileExtend->ProfileSetTones(); |
|
439 setTones.SetMessageAlertToneL(*XQConversions::qStringToS60Desc(filePath)); |
|
440 mEngine->CommitChangeL(*profileExtend); |
|
441 CleanupStack::Pop(); // profileExtend |
|
442 profileExtend->Release(); |
|
443 ) |
|
444 } |
|
445 |
|
446 /* |
|
447 * Get the email tone of a profile, if profile id is invalid, return an empty string |
|
448 */ |
|
449 QString CpProfileModelPrivate::emailTone(int profileId) const |
|
450 { |
|
451 QString emailTone; |
|
452 |
|
453 if(!isValidProfile(profileId)) { |
|
454 return emailTone; |
|
455 } |
|
456 QT_TRAP_THROWING( |
|
457 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
458 CleanupStack::PushL(profileExtend); |
|
459 const MProfileExtraTones2 &extTones = |
|
460 profileExtend->ProfileExtraTones2(); |
|
461 |
|
462 emailTone = XQConversions::s60DescToQString(extTones.EmailAlertTone()); |
|
463 CleanupStack::Pop(); // profileExtend |
|
464 profileExtend->Release(); |
|
465 ) |
|
466 return emailTone; |
|
467 } |
|
468 |
|
469 /* |
|
470 * Set the email tone for a profile, if the profile id is invalid, nothing happens |
|
471 */ |
|
472 void CpProfileModelPrivate::setEmailTone(int profileId, const QString& filePath) |
|
473 { |
|
474 if(!isValidProfile(profileId)) { |
|
475 return ; |
|
476 } |
|
477 QT_TRAP_THROWING( |
|
478 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
479 CleanupStack::PushL(profileExtend); |
|
480 MProfileSetExtraTones2 &setExtTones = |
|
481 profileExtend->ProfileSetExtraTones2(); |
|
482 setExtTones.SetEmailAlertToneL(*XQConversions::qStringToS60Desc(filePath)); |
|
483 mEngine->CommitChangeL(*profileExtend); |
|
484 CleanupStack::Pop(); // profileExtend |
|
485 profileExtend->Release(); |
|
486 ) |
|
487 } |
|
488 |
|
489 /* |
|
490 * Get a reminder tone for a profile, if the profile id is invalid, |
|
491 * always return an emtpy string |
|
492 */ |
|
493 QString CpProfileModelPrivate::reminderTone(int profileId) const |
|
494 { |
|
495 QString reminderTone; |
|
496 if(!isValidProfile(profileId)) { |
|
497 return reminderTone; |
|
498 } |
|
499 QT_TRAP_THROWING( |
|
500 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
501 CleanupStack::PushL(profileExtend); |
|
502 const MProfileExtraTones2 &extTones = profileExtend->ProfileExtraTones2(); |
|
503 |
|
504 reminderTone = XQConversions::s60DescToQString(extTones.ReminderTone()); |
|
505 CleanupStack::Pop(); // profileExtend |
|
506 profileExtend->Release(); |
|
507 ) |
|
508 return reminderTone; |
|
509 } |
|
510 |
|
511 /* |
|
512 * Set a reminder tone for a profile, if the profile id is invalid, |
|
513 * nothing happens |
|
514 */ |
|
515 void CpProfileModelPrivate::setReminderTone(int profileId, const QString& filePath) |
|
516 { |
|
517 if(!isValidProfile(profileId)) { |
|
518 return; |
|
519 } |
|
520 QT_TRAP_THROWING( |
|
521 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
522 CleanupStack::PushL(profileExtend); |
|
523 |
|
524 MProfileSetExtraTones2 &setExtTones = profileExtend->ProfileSetExtraTones2(); |
|
525 setExtTones.SetReminderToneL( *XQConversions::qStringToS60Desc(filePath) ); |
|
526 mEngine->CommitChangeL(*profileExtend); |
|
527 CleanupStack::Pop(); // profileExtend |
|
528 profileExtend->Release(); |
|
529 ) |
|
530 } |
|
531 |
|
532 /* |
|
533 * Get the status of notification tone, if the profile id is invalid, |
|
534 * always return false |
|
535 */ |
|
536 bool CpProfileModelPrivate::notificationTone(int profileId) const |
|
537 { |
|
538 bool ret = false; |
|
539 if(!isValidProfile(profileId)) { |
|
540 return false; |
|
541 } |
|
542 QT_TRAP_THROWING( |
|
543 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
544 CleanupStack::PushL(profileExtend); |
|
545 |
|
546 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
547 const TProfileToneSettings &toneSettings = setTones.ToneSettings(); |
|
548 ret = toneSettings.iWarningAndGameTones; |
|
549 |
|
550 CleanupStack::Pop(); // profileExtend |
|
551 profileExtend->Release(); |
|
552 ) |
|
553 return ret; |
|
554 } |
|
555 |
|
556 /* |
|
557 * Set the status of notification tone, if the profile id is |
|
558 * invalid, nothing happens |
|
559 */ |
|
560 void CpProfileModelPrivate::setNotificationTone(int profileId, bool isActive) |
|
561 { |
|
562 if(!isValidProfile(profileId)) { |
|
563 return ; |
|
564 } |
|
565 QT_TRAP_THROWING( |
|
566 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
567 CleanupStack::PushL(profileExtend); |
|
568 MProfileSetTones &setTones = profileExtend->ProfileSetTones(); |
|
569 TProfileToneSettings &toneSettings = setTones.SetToneSettings(); |
|
570 |
|
571 toneSettings.iWarningAndGameTones = isActive; |
|
572 |
|
573 mEngine->CommitChangeL(*profileExtend); |
|
574 CleanupStack::Pop(); // profileExtend |
|
575 profileExtend->Release(); |
|
576 ) |
|
577 } |
|
578 /* |
|
579 * Get key & touch screen tone's value, if the profile id |
|
580 * is invalid, always return 0 |
|
581 */ |
|
582 int CpProfileModelPrivate::keyTouchScreenTone(int profileId) const |
|
583 { |
|
584 int level = 0; |
|
585 if(!isValidProfile(profileId)) { |
|
586 return level; |
|
587 } |
|
588 |
|
589 QT_TRAP_THROWING( |
|
590 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
591 CleanupStack::PushL(profileExtend); |
|
592 |
|
593 const MProfileTones &setTones = profileExtend->ProfileTones(); |
|
594 const TProfileToneSettings &toneSettings = setTones.ToneSettings(); |
|
595 |
|
596 // Return only keypad volume, but touch tone volume will be synchronized in |
|
597 // SetKeyTouchScreenTone(), these two settings also have the same default value |
|
598 // in cenrep key |
|
599 level = toneSettings.iKeypadVolume; |
|
600 CleanupStack::Pop(); // profileExtend |
|
601 profileExtend->Release(); |
|
602 ) |
|
603 return level; |
|
604 } |
|
605 /* |
|
606 * set key & touch screen tone, if the profile id |
|
607 * is invalid, nothing happens |
|
608 */ |
|
609 void CpProfileModelPrivate::setKeyTouchScreenTone(int profileId, int level) |
|
610 { |
|
611 if(!isValidProfile(profileId)) { |
|
612 return ; |
|
613 } |
|
614 QT_TRAP_THROWING( |
|
615 |
|
616 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
617 CleanupStack::PushL(profileExtend); |
|
618 MProfileSetTones &setTones = |
|
619 profileExtend->ProfileSetTones(); |
|
620 TProfileToneSettings &toneSettings = |
|
621 setTones.SetToneSettings(); |
|
622 |
|
623 MProfileSetExtraSettings &extraSettings = |
|
624 profileExtend->ProfileSetExtraSettings(); |
|
625 MProfileSetFeedbackSettings &setFeedbackSettings = |
|
626 extraSettings.ProfileSetFeedbackSettings(); |
|
627 |
|
628 // Update the key pad volume and touch tone volume together |
|
629 toneSettings.iKeypadVolume |
|
630 = static_cast<TProfileKeypadVolume> (level); |
|
631 |
|
632 setFeedbackSettings.SetAudioFeedback( |
|
633 static_cast<TProfileAudioFeedback> (level)); |
|
634 |
|
635 mEngine->CommitChangeL(*profileExtend); |
|
636 CleanupStack::Pop(); // profileExtend |
|
637 profileExtend->Release(); |
|
638 ) |
|
639 } |
|
640 |
|
641 /* |
|
642 * Get key touch screen vibra's value of a profile, return 0 if the |
|
643 * profile id is invalid |
|
644 */ |
|
645 int CpProfileModelPrivate::keyTouchScreenVibra(int profileId)const |
|
646 { |
|
647 int level = 0; |
|
648 if(!isValidProfile(profileId)) { |
|
649 return level; |
|
650 } |
|
651 QT_TRAP_THROWING( |
|
652 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
653 CleanupStack::PushL(profileExtend); |
|
654 const MProfileExtraSettings &extraSettings = |
|
655 profileExtend->ProfileExtraSettings(); |
|
656 const MProfileFeedbackSettings &feedbackSettings = |
|
657 extraSettings.ProfileFeedbackSettings(); |
|
658 level = feedbackSettings.TactileFeedback(); |
|
659 |
|
660 CleanupStack::Pop(); // profileExtend |
|
661 profileExtend->Release(); |
|
662 ) |
|
663 |
|
664 return level; |
|
665 } |
|
666 |
|
667 /* |
|
668 * Set key & touch screen vibra for a profile, |
|
669 * if the profile id is invalid, nothing happens |
|
670 */ |
|
671 void CpProfileModelPrivate::setKeyTouchScreenVibra(int profileId, int level) |
|
672 { |
|
673 if(!isValidProfile(profileId)) { |
|
674 return ; |
|
675 } |
|
676 QT_TRAP_THROWING( |
|
677 MProfileExtended2 *profileExtend = mEngine->Profile2L(profileId); |
|
678 CleanupStack::PushL(profileExtend); |
|
679 |
|
680 MProfileSetExtraSettings &extraSettings = |
|
681 profileExtend->ProfileSetExtraSettings(); |
|
682 MProfileSetFeedbackSettings &setFeedbackSettings = |
|
683 extraSettings.ProfileSetFeedbackSettings(); |
|
684 setFeedbackSettings.SetTactileFeedback( |
|
685 static_cast<TProfileTactileFeedback> (level)); |
|
686 mEngine->CommitChangeL(*profileExtend); |
|
687 CleanupStack::Pop(); // profileExtend |
|
688 profileExtend->Release(); |
|
689 ) |
|
690 } |
|
691 |
|
692 /* |
|
693 * Judge the profile is valid or not |
|
694 */ |
|
695 |
|
696 bool CpProfileModelPrivate::isValidProfile(int profileId) const |
|
697 { |
|
698 return mProfileList.contains(profileId); |
|
699 } |
|
700 |
|
701 // End of file |
|
702 |
|
703 |