--- a/controlpanelui/src/cpprofilewrapper/src/cpprofilemodel_p.cpp Mon May 03 12:32:06 2010 +0300
+++ b/controlpanelui/src/cpprofilewrapper/src/cpprofilemodel_p.cpp Fri May 14 15:53:07 2010 +0300
@@ -20,6 +20,7 @@
#include <cplogger.h>
#include <e32base.h>
#include <QString>
+#include <QMap>
#include <MProfileEngineExtended2.h>
#include <MProfileExtended.h>
#include <MProfileName.h>
@@ -58,13 +59,7 @@
CpProfileModelPrivate::CpProfileModelPrivate()
: mEngine(0),
- //mProfileExt(0),
- //mToneSettings(0),
- //mFeedbackSettings(0),
- //mSetFeedbackSettings(0),
- //mVibraCenRep(0),
- mEditingProfileId(0),
- mInitErrFlag(false),
+ mInitErrFlag(0),
mOffLineCenRep(0),
q_ptr(0)
{
@@ -77,52 +72,43 @@
CPFW_LOG("CpProfileModelPrivate::CpProfileModelPrivate(), START.");
TRAPD( err,
mEngine = CreateProfileEngineExtended2L();
- //int proId = mEngine->ActiveProfileId();
- //UpdateProfileSettingsL( proId );
- //mVibraCenRep = CRepository::NewL( KCRUidVibraCtrl );
mOffLineCenRep = CRepository::NewL( KCRUidCommunicationSettings );
+
+ /*
+ * Currently, engine part will return all previous version of profile
+ * so some invalid profile will be added in the new list, to avoid this
+ * use hard code to get the right list of profile.
+ */
+ /*MProfilesNamesArray* nameList = mEngine->ProfilesNamesArrayLC();
+ int profileCount = nameList->MdcaCount();
+ for (int i = 0; i<profileCount; i++) {
+ MProfileName *profileName = nameList->ProfileName(i);
+ mProfileList.insert(profileName->Id(), mEngine->Profile2L(profileName->Id()));
+ }
+ CleanupStack::PopAndDestroy(*nameList);*/
+ mProfileList.insert(0, mEngine->Profile2L(0)); // general id
+ mProfileList.insert(2, mEngine->Profile2L(2));
);
+
+ // currently, reserve a error code for deal with low memory ... leave
+ // as known, qt in symbian exception safety's development is ongoing.
+ // we will follow the official way to deal with symbian leave or exception
mInitErrFlag = err;
CPFW_LOG("CpProfileModelPrivate::CpProfileModelPrivate(), END, err is." + QString(err) );
}
-void CpProfileModelPrivate::UpdateProfileSettingsL(int profileId)
-{
- CPFW_LOG("CpProfileModelPrivate::UpdateProfileSettingsL(), START. profile id is: " + QString(profileId));
- /*if ( profileId <= EProfileWrapperErrorId || profileId >= EProfileWrapperOverflowId ){
- CPFW_LOG("CpProfileModelPrivate::UpdateProfileSettingsL(), End with invalid profile id.");
- //User::Leave(KErrNotFound);
- return;
- }
-*/
-/* mProfileExt = mEngine->Profile2L( profileId );
- CPFW_LOG("CpProfileModelPrivate::UpdateProfileSettingsL(), Succeded in getting mProfileExt. ");
-
- // General tones
- TProfileToneSettings& toneSettings = mProfileExt->ProfileSetTones().SetToneSettings();
- mToneSettings = &toneSettings;
-
- // Feedback settings, used to get screen tone
- const MProfileFeedbackSettings& feedback =
- mProfileExt->ProfileExtraSettings().ProfileFeedbackSettings();
- mFeedbackSettings = &feedback;
-
- // Feedback settings, used to set screen tone
- MProfileSetFeedbackSettings& setFeedback =
- mProfileExt->ProfileSetExtraSettings().ProfileSetFeedbackSettings();
- mSetFeedbackSettings = &setFeedback;
-
- mEditingProfileId = profileId;
- CPFW_LOG("CpProfileModelPrivate::UpdateProfileSettingsL(), END.");*/
-}
CpProfileModelPrivate::~CpProfileModelPrivate()
{
- //delete mEngine;
if (mEngine!=0) {
mEngine->Release();
}
- //delete mVibraCenRep;
- //mVibraCenRep = 0;
+ foreach(MProfileExtended2* profile, mProfileList)
+ {
+ if (profile!=0 ) {
+ profile->Release();
+ }
+ }
+ mProfileList.clear();
delete mOffLineCenRep;
}
@@ -153,6 +139,7 @@
// }
// should return qt localized profile name
// engine return symbian localized name, that is a wrong way to got it
+ // so hard code here, wait for engine's correcting.
switch (profileId) {
case EProfileWrapperGeneralId:
return hbTrId("txt_cp_setlabel_active_profile_val_general");
@@ -190,23 +177,15 @@
/*
* Get active profile's id
*/
-int CpProfileModelPrivate::activeProfileId()
+int CpProfileModelPrivate::activeProfileId() const
{
return mEngine->ActiveProfileId();
}
-int CpProfileModelPrivate::profileSettings(int profileId,
+void CpProfileModelPrivate::profileSettings(int profileId,
CpProfileSettings& profileSettings)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
-// CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return err;
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
const MProfileTones &setTones = profileExtend->ProfileTones();
const TProfileToneSettings &toneSettings = setTones.ToneSettings();
const MProfileExtraTones2 &extTones = profileExtend->ProfileExtraTones2();
@@ -216,8 +195,7 @@
profileExtend->ProfileExtraSettings();
const MProfileFeedbackSettings &feedbackSettings =
extraSettings.ProfileFeedbackSettings();
-
-
+
profileSettings.mRingTone = stringFromDescriptor(setTones.RingingTone1());
profileSettings.mMessageTone = stringFromDescriptor(setTones.MessageAlertTone());
profileSettings.mEmailTone = stringFromDescriptor(extTones.EmailAlertTone());
@@ -231,105 +209,92 @@
profileSettings.mReminderAlertVibra = vibraSettings.ReminderAlarmVibra();
profileSettings.mNotificationVibra = vibraSettings.InformationVibra();
profileSettings.mKeyTouchScreenVibra = feedbackSettings.TactileFeedback();
-
- CleanupStack::PopAndDestroy(profileExtend);
- return err;
+
}
int CpProfileModelPrivate::setProfileSettings(int profileId, CpProfileSettings& profileSettings)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
-
- )
- if (err!=KErrNone) {
- return err;
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
MProfileSetTones &setTones = profileExtend->ProfileSetTones();
TProfileToneSettings &toneSettings = setTones.SetToneSettings();
- MProfileSetExtraTones2 &setExtTones = profileExtend->ProfileSetExtraTones2();
- MProfileSetVibraSettings &setVibraSettings = profileExtend->ProfileSetVibraSettings();
- MProfileSetExtraSettings &extraSettings = profileExtend->ProfileSetExtraSettings();
- MProfileSetFeedbackSettings &setFeedbackSettings = extraSettings.ProfileSetFeedbackSettings();
-
+ MProfileSetExtraTones2 &setExtTones =
+ profileExtend->ProfileSetExtraTones2();
+ MProfileSetVibraSettings &setVibraSettings =
+ profileExtend->ProfileSetVibraSettings();
+ MProfileSetExtraSettings &extraSettings =
+ profileExtend->ProfileSetExtraSettings();
+ MProfileSetFeedbackSettings &setFeedbackSettings =
+ extraSettings.ProfileSetFeedbackSettings();
+ // ignore here, wait for the exception deal framework of qt-symbian
TRAP_IGNORE(
- setTones.SetRingingTone1L( *descriptorFromString(profileSettings.mRingTone) );
- setTones.SetMessageAlertToneL( *descriptorFromString(profileSettings.mMessageTone) );
- setExtTones.SetEmailAlertToneL( *descriptorFromString(profileSettings.mEmailTone) );
- setExtTones.SetReminderToneL( *descriptorFromString(profileSettings.mReminderTone) );
+ setTones.SetRingingTone1L(*descriptorFromString(
+ profileSettings.mRingTone));
+ setTones.SetMessageAlertToneL(*descriptorFromString(
+ profileSettings.mMessageTone));
+ setExtTones.SetEmailAlertToneL(*descriptorFromString(
+ profileSettings.mEmailTone));
+ setExtTones.SetReminderToneL(*descriptorFromString(
+ profileSettings.mReminderTone));
)
+ toneSettings.iWarningAndGameTones
+ = profileSettings.mNotificationTone;
+ toneSettings.iKeypadVolume
+ = static_cast<TProfileKeypadVolume> (profileSettings.mKeyTouchScreenTone);
+ setVibraSettings.SetRingAlertVibra(profileSettings.mRingAlertVibra);
+ setVibraSettings.SetMessageAlertVibra(profileSettings.mMessageVibra);
+ setVibraSettings.SetEmailAlertVibra(profileSettings.mEmailVibra);
+ setVibraSettings.SetReminderAlarmVibra(
+ profileSettings.mReminderAlertVibra);
+ setVibraSettings.SetInformationVibra(
+ profileSettings.mNotificationVibra);
+ setFeedbackSettings.SetTactileFeedback(
+ static_cast<TProfileTactileFeedback> (profileSettings.mKeyTouchScreenVibra));
- toneSettings.iWarningAndGameTones = profileSettings.mNotificationTone;
- toneSettings.iKeypadVolume = static_cast<TProfileKeypadVolume>(profileSettings.mKeyTouchScreenTone);
- setVibraSettings.SetRingAlertVibra( profileSettings.mRingAlertVibra );
- setVibraSettings.SetMessageAlertVibra ( profileSettings.mMessageVibra );
- setVibraSettings.SetEmailAlertVibra ( profileSettings.mEmailVibra );
- setVibraSettings.SetReminderAlarmVibra ( profileSettings.mReminderAlertVibra );
- setVibraSettings.SetInformationVibra ( profileSettings.mNotificationVibra );
- setFeedbackSettings.SetTactileFeedback(static_cast<TProfileTactileFeedback>(profileSettings.mKeyTouchScreenVibra));
-
- TRAPD(err2,
- mEngine->CommitChangeL(*profileExtend);
- CleanupStack::PopAndDestroy(profileExtend);
- )
- return err2;
+ TRAPD(err,
+ mEngine->CommitChangeL(*profileExtend);
+ )
+ return err;
}
QString CpProfileModelPrivate::ringTone() const
{
- MProfileExtended2 *profileExtend = 0;
-
- TRAPD(err,
- profileExtend = mEngine->Profile2L(EProfileWrapperGeneralId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err!=KErrNone) {
- return QString("");
- }
- CleanupReleasePushL(*profileExtend);
-
- QString ringTone = stringFromDescriptor(profileExtend->ProfileTones().RingingTone1());
- CleanupStack::PopAndDestroy(profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(EProfileWrapperGeneralId);
+ QString ringTone = stringFromDescriptor(
+ profileExtend->ProfileTones().RingingTone1());
return ringTone;
- CPFW_LOG("CpProfileModelPrivate::ringTone(), END with invalid mProfileExt. ");
-
}
void CpProfileModelPrivate::setRingTone(const QString& filePath)
{
- TInt ids[] = {EProfileGeneralId,EProfileMeetingId};
-
- for (TInt i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i)
- {
- MProfileExtended2 *profileExtend = 0;
+ int ids[] = {EProfileWrapperGeneralId,EProfileWrapperMeetingId};
+
+ for (TInt i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i) {
+ MProfileExtended2 *profileExtend = mProfileList.value(ids[i]);
+
+ MProfileSetTones &setTones = profileExtend->ProfileSetTones();
TRAP_IGNORE(
- profileExtend = mEngine->Profile2L(ids[i]);
+ setTones.SetRingingTone1L( *descriptorFromString(filePath) );
+ mEngine ->CommitChangeL(*profileExtend);
)
- CleanupReleasePushL(*profileExtend);
- MProfileSetTones &setTones = profileExtend->ProfileSetTones();
- setTones.SetRingingTone1L( *descriptorFromString(filePath) );
- mEngine ->CommitChangeL(*profileExtend);
- CleanupStack::PopAndDestroy(profileExtend);
- }
+ // ERROR SHOULD BE DEAL HERE OR RETURN A ERROR CODE
+ }
}
int CpProfileModelPrivate::masterVolume() const
{
- //NEED L FUNCTION?
- TInt masterVolume = mEngine->MasterVolumeL();
+ int masterVolume = 0;
+ TRAP_IGNORE(masterVolume = mEngine->MasterVolumeL();)
return masterVolume;
}
void CpProfileModelPrivate::setMasterVolume(int volume)
{
- //NEED L FUNCTION ?
TRAP_IGNORE(mEngine->SetMasterVolumeL( volume );)
}
bool CpProfileModelPrivate::masterVibra() const
{
- bool masterVibra = mEngine->MasterVibraL();
+ bool masterVibra = false;
+ TRAP_IGNORE(masterVibra = mEngine->MasterVibraL();)
return masterVibra;
}
void CpProfileModelPrivate::setMasterVibra(bool isVibra)
@@ -337,9 +302,10 @@
TRAP_IGNORE(mEngine->SetMasterVibraL( isVibra );)
}
-bool CpProfileModelPrivate::isSilenceMode() const
+bool CpProfileModelPrivate::silenceMode() const
{
- bool isSlience = mEngine->SilenceModeL();
+ bool isSlience = false;
+ TRAP_IGNORE(isSlience = mEngine->SilenceModeL();)
return isSlience;
}
void CpProfileModelPrivate::setSilenceMode(bool isSilence)
@@ -347,257 +313,147 @@
TRAP_IGNORE(mEngine->SetSilenceModeL( isSilence );)
}
-bool CpProfileModelPrivate::isOffLineMode() const
+bool CpProfileModelPrivate::offLineMode() const
{
int offLineMode = 0;
- User::LeaveIfError(mOffLineCenRep->Get( KSettingsAirplaneMode, offLineMode ));
+ // What we should do if we can't set offline mode
+ mOffLineCenRep->Get( KSettingsAirplaneMode, offLineMode );
return offLineMode;
}
void CpProfileModelPrivate::setOffLineMode(bool isOffLine)
{
- User::LeaveIfError(mOffLineCenRep->Set(KSettingsAirplaneMode, isOffLine));
+ mOffLineCenRep->Set(KSettingsAirplaneMode, isOffLine);
}
QString CpProfileModelPrivate::ringTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return QString("");
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
const MProfileTones &setTones = profileExtend->ProfileTones();
-
-
+
QString ringTone = stringFromDescriptor(setTones.RingingTone1());
- CleanupStack::PopAndDestroy(profileExtend);
return ringTone;
}
void CpProfileModelPrivate::setRingTone(int profileId, const QString& filePath)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetTones &setTones = profileExtend->ProfileSetTones();
-
- TRAP_IGNORE(
- setTones.SetRingingTone1L( *descriptorFromString(filePath) );
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetTones &setTones = profileExtend->ProfileSetTones();
+ TRAP_IGNORE(
+ setTones.SetRingingTone1L(*descriptorFromString(filePath));
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
QString CpProfileModelPrivate::messageTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return QString("");
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+
const MProfileTones &setTones = profileExtend->ProfileTones();
-
+
QString messageTone = stringFromDescriptor(setTones.MessageAlertTone());
-
- CleanupStack::PopAndDestroy(profileExtend);
+
return messageTone;
-
}
void CpProfileModelPrivate::setMessageTone(int profileId, const QString& filePath)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetTones &setTones = profileExtend->ProfileSetTones();
-
- TRAP_IGNORE(
- setTones.SetMessageAlertToneL( *descriptorFromString(filePath) );
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
-
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetTones &setTones =
+ profileExtend->ProfileSetTones();
+ TRAP_IGNORE(
+ setTones.SetMessageAlertToneL(*descriptorFromString(filePath));
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
QString CpProfileModelPrivate::emailTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return QString("");
- }
- CleanupReleasePushL(*profileExtend);
- const MProfileExtraTones2 &extTones = profileExtend->ProfileExtraTones2();
-
- QString emailTone = stringFromDescriptor(extTones.EmailAlertTone());
-
- CleanupStack::PopAndDestroy(profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ const MProfileExtraTones2 &extTones =
+ profileExtend->ProfileExtraTones2();
+
+ QString emailTone = stringFromDescriptor(extTones.EmailAlertTone());
return emailTone;
-
}
void CpProfileModelPrivate::setEmailTone(int profileId, const QString& filePath)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetExtraTones2 &setExtTones = profileExtend->ProfileSetExtraTones2();
-
- TRAP_IGNORE(
- setExtTones.SetEmailAlertToneL( *descriptorFromString(filePath) );
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetExtraTones2 &setExtTones =
+ profileExtend->ProfileSetExtraTones2();
+ TRAP_IGNORE (
+ setExtTones.SetEmailAlertToneL(*descriptorFromString(filePath));
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
QString CpProfileModelPrivate::reminderTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return QString("");
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
const MProfileExtraTones2 &extTones = profileExtend->ProfileExtraTones2();
QString reminderTone = stringFromDescriptor(extTones.ReminderTone());
-
- CleanupStack::PopAndDestroy(profileExtend);
- return reminderTone;
-
+ return reminderTone;
}
void CpProfileModelPrivate::setReminderTone(int profileId, const QString& filePath)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetExtraTones2 &setExtTones = profileExtend->ProfileSetExtraTones2();
-
- TRAP_IGNORE(
- setExtTones.SetReminderToneL( *descriptorFromString(filePath) );
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetExtraTones2 &setExtTones = profileExtend->ProfileSetExtraTones2();
+
+ TRAP_IGNORE(
+ setExtTones.SetReminderToneL( *descriptorFromString(filePath) );
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
bool CpProfileModelPrivate::notificationTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return false; // ??????
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
const MProfileTones &setTones = profileExtend->ProfileTones();
const TProfileToneSettings &toneSettings = setTones.ToneSettings();
-
+
bool notificationTone = toneSettings.iWarningAndGameTones;
-
- CleanupStack::PopAndDestroy(profileExtend);
- return notificationTone;
+ return notificationTone;
}
void CpProfileModelPrivate::setNotificationTone(int profileId, bool isActive)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetTones &setTones = profileExtend->ProfileSetTones();
- TProfileToneSettings &toneSettings = setTones.SetToneSettings();
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetTones &setTones = profileExtend->ProfileSetTones();
+ TProfileToneSettings &toneSettings = setTones.SetToneSettings();
-
- toneSettings.iWarningAndGameTones = isActive;
-
- TRAP_IGNORE(
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
+ toneSettings.iWarningAndGameTones = isActive;
+ TRAP_IGNORE(
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
int CpProfileModelPrivate::keyTouchScreenTone(int profileId) const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return -1;
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+
const MProfileTones &setTones = profileExtend->ProfileTones();
const TProfileToneSettings &toneSettings = setTones.ToneSettings();
-
+
int keyTouchScreenTone = toneSettings.iKeypadVolume;
-
- CleanupStack::PopAndDestroy(profileExtend);
- return keyTouchScreenTone;
-
+ return keyTouchScreenTone;
}
void CpProfileModelPrivate::setKeyTouchScreenTone(int profileId, int level)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetTones &setTones = profileExtend->ProfileSetTones();
- TProfileToneSettings &toneSettings = setTones.SetToneSettings();
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetTones &setTones =
+ profileExtend->ProfileSetTones();
+ TProfileToneSettings &toneSettings =
+ setTones.SetToneSettings();
- toneSettings.iKeypadVolume = static_cast<TProfileKeypadVolume>(level);
-
- TRAP_IGNORE(
- mEngine->CommitChangeL(*profileExtend);
- )
- CleanupStack::PopAndDestroy(profileExtend);
- }
-
+ toneSettings.iKeypadVolume
+ = static_cast<TProfileKeypadVolume> (level);
+ TRAP_IGNORE (
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
bool CpProfileModelPrivate::ringAlertVibra(int profileId) const
@@ -810,411 +666,32 @@
int CpProfileModelPrivate::keyTouchScreenVibra(int profileId)const
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD(err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err != KErrNone) {
- return -1;
- }
- CleanupReleasePushL(*profileExtend);
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+
const MProfileExtraSettings &extraSettings =
profileExtend->ProfileExtraSettings();
const MProfileFeedbackSettings &feedbackSettings =
extraSettings.ProfileFeedbackSettings();
-
- bool keyTouchScreenVibra = feedbackSettings.TactileFeedback();
-
- CleanupStack::PopAndDestroy(profileExtend);
- return keyTouchScreenVibra;
-
+ int keyTouchScreenVibra = feedbackSettings.TactileFeedback();
+ return keyTouchScreenVibra;
}
void CpProfileModelPrivate::setKeyTouchScreenVibra(int profileId, int level)
{
- MProfileExtended2 *profileExtend = 0;
- TRAPD( err,
- profileExtend = mEngine->Profile2L(profileId);
- //CleanupReleasePushL(*profileExtend);
- )
- if (err==KErrNone) {
- CleanupReleasePushL(*profileExtend);
- MProfileSetExtraSettings &extraSettings = profileExtend->ProfileSetExtraSettings();
- MProfileSetFeedbackSettings &setFeedbackSettings = extraSettings.ProfileSetFeedbackSettings();
- setFeedbackSettings.SetTactileFeedback(static_cast<TProfileTactileFeedback>(level));
-
- TRAP_IGNORE(
- mEngine->CommitChangeL(*profileExtend);
- )
+ MProfileExtended2 *profileExtend = mProfileList.value(profileId);
+ MProfileSetExtraSettings &extraSettings =
+ profileExtend->ProfileSetExtraSettings();
+ MProfileSetFeedbackSettings &setFeedbackSettings =
+ extraSettings.ProfileSetFeedbackSettings();
+ setFeedbackSettings.SetTactileFeedback(
+ static_cast<TProfileTactileFeedback> (level));
- CleanupStack::PopAndDestroy(profileExtend);
- }
-}
-///*
-// * Set a profile as current editing profile
-// */
-//int CpProfileModelPrivate::setEditingProfile(int profileId)
-//{
-// CPFW_LOG("CpProfileModelPrivate::setEditingProfile(), START.");
-// TRAPD( err, UpdateProfileSettingsL( profileId ););
-// CPFW_LOG("CpProfileModelPrivate::setEditingProfile(), END.");
-// return err;
-//}
-//
-///*
-// * Get path and file name of ring tone file
-// */
-//QString CpProfileModelPrivate::ringTone()
-//{
-// if ( mProfileExt ){
-// return stringFromDescriptor( mProfileExt->ProfileTones().RingingTone1() );
-// }
-// CPFW_LOG("CpProfileModelPrivate::ringTone(), END with invalid mProfileExt. ");
-// return "";
-//}
-//
-///*
-// * Set path and file to ring tone
-// */
-//int CpProfileModelPrivate::setRingTone(const QString& filePath)
-//{
-// if ( mProfileExt ){
-// TRAPD(err, mProfileExt->ProfileSetTones().SetRingingTone1L( *descriptorFromString(filePath) ));
-// commitChange();
-// return err;
-// }
-// CPFW_LOG("CpProfileModelPrivate::setRingTone(), END with invalid mProfileExt.");
-// return -1;
-//}
-//
-///*
-// * Get path and file name of message tone file
-// */
-//QString CpProfileModelPrivate::messageTone()
-//{
-// if ( mProfileExt ){
-// return stringFromDescriptor( mProfileExt->ProfileTones().MessageAlertTone() );
-// }
-// CPFW_LOG("CpProfileModelPrivate::messageTone(), END with invalid mProfileExt.");
-// return "";
-//}
-//
-///*
-// * Set path and file to message tone
-// */
-//int CpProfileModelPrivate::setMessageTone(const QString& filePath)
-//{
-// if ( mProfileExt ){
-// TRAPD(err, mProfileExt->ProfileSetTones().SetMessageAlertToneL( *descriptorFromString(filePath) ));
-// commitChange();
-// return err;
-// }
-// CPFW_LOG("CpProfileModelPrivate::setMessageTone(), END with invalid mProfileExt.");
-// return -1;
-//}
-//
-///*
-// * Get path and file name of email tone file
-// */
-//QString CpProfileModelPrivate::emailTone()
-//{
-// if ( mProfileExt ){
-// return stringFromDescriptor( mProfileExt->ProfileExtraTones().EmailAlertTone() );
-// }
-// CPFW_LOG("CpProfileModelPrivate::emailTone(), END with invalid mProfileExt.");
-// return "";
-//}
-//
-///*
-// * Set path and file to email tone
-// */
-//int CpProfileModelPrivate::setEmailTone(const QString& filePath)
-//{
-// if ( mProfileExt ){
-// TRAPD(err, mProfileExt->ProfileSetExtraTones().SetEmailAlertToneL( *descriptorFromString(filePath) ));
-// commitChange();
-// return err;
-// }
-// CPFW_LOG("CpProfileModelPrivate::setEmailTone(), END with invalid mProfileExt.");
-// return -1;
-//}
-//
-///*
-// * Get path and file name of calendar event tone file
-// */
-//QString CpProfileModelPrivate::calendarTone()
-//{
-// return "";
-//}
-//
-///*
-// * Set path and file to calendar event tone
-// */
-//void CpProfileModelPrivate::setCalendarTone(const QString& filePath)
-//{
-// Q_UNUSED(filePath);
-//}
-//
-///*
-// * Get path and file name of clock alarm tone file
-// */
-//QString CpProfileModelPrivate::alarmTone()
-//{
-// return "";
-//}
-//
-///*
-// * Set path and file to clock alarm tone
-// */
-//void CpProfileModelPrivate::setAlarmTone(const QString& filePath)
-//{
-// Q_UNUSED(filePath);
-//}
-//
-///*
-// * Get the value of master volume
-// */
-//int CpProfileModelPrivate::ringVolume()
-//{
-// CPFW_LOG("CpProfileModelPrivate::ringVolume(), START.");
-// if ( mToneSettings ){
-// CPFW_LOG("CpProfileModelPrivate::ringVolume(), End.");
-// return mToneSettings->iRingingVolume;
-// }
-// CPFW_LOG("CpProfileModelPrivate::ringVolume(), END with invalid mToneSettings.");
-// return -1;
-//}
-//
-///*
-// * Set master volume, the value should be between 1-10
-// */
-//void CpProfileModelPrivate::setRingVolume(int volume)
-//{
-// CPFW_LOG("CpProfileModelPrivate::setRingVolume(), START.");
-// if ( !mToneSettings ) {
-// CPFW_LOG("CpProfileModelPrivate::setRingVolume(), END with invalid mToneSettings.");
-// return;
-// }
-// if ( EProfileWrapperSilentId == mEditingProfileId || volume < 0 || volume >10 )
-// {
-// return;
-// }
-//
-// mToneSettings->iRingingType = EProfileRingingTypeRinging;
-// mToneSettings->iRingingVolume = volume;
-// commitChange();
-//
-// // General profile and meeting profile should have same ring tone volume
-// int profileId = activeProfileId();
-// if ( EProfileWrapperMeetingId == profileId ){
-// profileId = EProfileWrapperGeneralId;
-// } else if ( EProfileWrapperGeneralId == profileId ) {
-// profileId = EProfileWrapperMeetingId;
-// }
-// MProfileExtended* profileExt = 0;
-// TRAPD( err0, profileExt = mEngine->ProfileL( profileId ););
-// Q_UNUSED(err0);
-// TProfileToneSettings& toneSettings = profileExt->ProfileSetTones().SetToneSettings();
-// toneSettings.iRingingType = EProfileRingingTypeRinging;
-// toneSettings.iRingingVolume = volume;
-// TRAPD( err, mEngine->CommitChangeL(*profileExt) );
-// Q_UNUSED(err);
-// CPFW_LOG("CpProfileModelPrivate::setRingVolume(), END.");
-// // currently implementation: keep the two profiles same volume
-//}
-//
-///*
-// * Activate master volume to beep
-// */
-//void CpProfileModelPrivate::activateBeep()
-//{
-// if ( mToneSettings ){
-// mToneSettings->iRingingType = EProfileRingingTypeBeepOnce;
-// commitChange();
-// } else {
-// CPFW_LOG("CpProfileModelPrivate::activateBeep(), END with invalid mToneSettings.");
-// }
-//}
-//
-///*
-// * Get beep status in master volume
-// */
-//bool CpProfileModelPrivate::isBeep()
-//{
-// if ( mToneSettings ){
-// return (EProfileRingingTypeBeepOnce == mToneSettings->iRingingType) ? true : false;
-// }
-// CPFW_LOG("CpProfileModelPrivate::isBeep(), END with invalid mToneSettings.");
-// return false;
-//}
-//
-///*
-// * Activate master volume to silent
-// */
-//void CpProfileModelPrivate::activateSilent()
-//{
-// if ( mToneSettings ){
-// mToneSettings->iRingingType = EProfileRingingTypeSilent;
-// commitChange();
-// } else {
-// CPFW_LOG("CpProfileModelPrivate::vibraStatus(), END with invalid mToneSettings.");
-// }
-//}
-//
-///*
-// * Get silent status in master volume
-// */
-//bool CpProfileModelPrivate::isSilent()
-//{
-// if ( mToneSettings ){
-// return (EProfileRingingTypeSilent == mToneSettings->iRingingType) ? true : false;
-// } else {
-// CPFW_LOG("CpProfileModelPrivate::vibraStatus(), END with invalid mToneSettings.");
-// return false;
-// }
-//}
-//
-///*
-// * Get master vibra's status
-// */
-//bool CpProfileModelPrivate::vibraStatus()
-//{
-// CPFW_LOG("CpProfileModelPrivate::vibraStatus(), Start.");
-// if ( mToneSettings ){
-// CPFW_LOG("CpProfileModelPrivate::vibraStatus(), End.");
-// return mToneSettings->iVibratingAlert;
-// }
-// CPFW_LOG("CpProfileModelPrivate::vibraStatus(), END with invalid mToneSettings.");
-// return false;
-//}
-//
-///*
-// * Set master vibra's status
-// */
-//void CpProfileModelPrivate::setVibraStatus(bool status)
-//{
-// CPFW_LOG("CpProfileModelPrivate::setVibraStatus(), Start.");
-// if ( mVibraCenRep ){
-// mVibraCenRep->Set(KVibraCtrlProfileVibraEnabled, status );
-// }
-//
-// if ( mToneSettings ){
-// mToneSettings->iVibratingAlert = status;
-// commitChange();
-// }
-// CPFW_LOG("CpProfileModelPrivate::setVibraStatus(), END.");
-//}
-//
-///*
-// * Get keypad' volume
-// */
-//int CpProfileModelPrivate::keyVolume()
-//{
-// CPFW_LOG("CpProfileModelPrivate::keyVolume(), Start.");
-// if ( mToneSettings ){
-// CPFW_LOG("CpProfileModelPrivate::keyVolume(), END.");
-// return mToneSettings->iKeypadVolume;
-// }
-// CPFW_LOG("CpProfileModelPrivate::keyVolume(), END with invalid mToneSettings.");
-// return -1;
-//}
-//
-///*
-// * Set keypad's volume,
-// * the value of the volume should be between 0-3
-// */
-//void CpProfileModelPrivate::setKeyVolume(int volume)
-//{
-// CPFW_LOG("CpProfileModelPrivate::setKeyVolume(), Start.");
-// if (volume < 0 || volume > 3)
-// {
-// CPFW_LOG("CpProfileModelPrivate::setKeyVolume(), End with invalid volume.");
-// return;
-// }
-//
-// if ( mToneSettings ){
-// mToneSettings->iKeypadVolume = (TProfileKeypadVolume)volume;
-// commitChange();
-// }
-// CPFW_LOG("CpProfileModelPrivate::setKeyVolume(), End.");
-//}
-//
-///*
-// * Get screen tone's volume
-// */
-//int CpProfileModelPrivate::screenVolume()
-//{
-// CPFW_LOG("CpProfileModelPrivate::screenVolume(), Start.");
-// if ( mFeedbackSettings ){
-// CPFW_LOG("CpProfileModelPrivate::screenVolume(), End.");
-// return mFeedbackSettings->AudioFeedback();
-// }
-// CPFW_LOG("CpProfileModelPrivate::screenVolume(), End.");
-// return -1;
-//}
-//
-///*
-// * Set screen tone's volume,
-// * the value of the volume should be between 0-3
-// */
-//void CpProfileModelPrivate::setScreenVolume(int volume)
-//{
-// CPFW_LOG("CpProfileModelPrivate::setScreenVolume(), Start.");
-// if (volume < 0 || volume > 3)
-// {
-// CPFW_LOG("CpProfileModelPrivate::setScreenVolume(), End with invalid volume.");
-// return;
-// }
-//
-// if ( mSetFeedbackSettings ){
-// mSetFeedbackSettings->SetAudioFeedback( (TProfileAudioFeedback)volume );
-// commitChange();
-// }
-// CPFW_LOG("CpProfileModelPrivate::setScreenVolume(), End.");
-//}
-//
-///*
-// * Get screen vibra's level
-// */
-//int CpProfileModelPrivate::screenVibra()
-//{
-// CPFW_LOG("CpProfileModelPrivate::screenVibra(), Start.");
-// if ( mFeedbackSettings ){
-// CPFW_LOG("CpProfileModelPrivate::screenVibra(), End.");
-// return mFeedbackSettings->TactileFeedback();
-// }
-// CPFW_LOG("CpProfileModelPrivate::screenVibra(), End with invalid mFeedbackSettings.");
-// return -1;
-//}
-//
-///*
-// * Set screen vibra's level,
-// * the value of the level should be between 0-3
-// */
-//void CpProfileModelPrivate::setScreenVibra(int volume)
-//{
-// if (volume < 0 || volume > 3)
-// {
-// return;
-// }
-//
-// if ( mSetFeedbackSettings ){
-// mSetFeedbackSettings->SetTactileFeedback( (TProfileTactileFeedback)volume );
-// commitChange();
-// }
-//}
-
-/*
- * Commit changes when change settings value in profile.
- */
-int CpProfileModelPrivate::commitChange()
-{
- /* TRAPD( err, mEngine->CommitChangeL(*mProfileExt) );
- return err;*/
- return 0;
+ TRAP_IGNORE(
+ mEngine->CommitChangeL(*profileExtend);
+ )
}
// End of file
+