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