profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
changeset 21 851e19007849
parent 18 e3554c9069b6
child 23 7e4c5a2ff1a2
equal deleted inserted replaced
19:30540fccecae 21:851e19007849
    53 #include <data_caging_path_literals.hrh>
    53 #include <data_caging_path_literals.hrh>
    54 
    54 
    55 #include <psmsettings.h>
    55 #include <psmsettings.h>
    56 #include <psmsrvdomaincrkeys.h>
    56 #include <psmsrvdomaincrkeys.h>
    57 
    57 
       
    58 #include <MProfileExtraTones2.h>
       
    59 #include <MProfileVibraSettings.h>
       
    60 
    58 
    61 
    59 // ============================ MEMBER FUNCTIONS ===============================
    62 // ============================ MEMBER FUNCTIONS ===============================
    60 
    63 
    61 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    62 // CProfileEngineImpl::NewL
    65 // CProfileEngineImpl::NewL
   235 // -----------------------------------------------------------------------------
   238 // -----------------------------------------------------------------------------
   236 //
   239 //
   237 MProfileExtended* CProfileEngineImpl::ProfileLC(
   240 MProfileExtended* CProfileEngineImpl::ProfileLC(
   238     TInt aId )
   241     TInt aId )
   239     {
   242     {
       
   243     return Profile2LC( aId );
       
   244     /*
   240     CProfileImpl* profile = NULL;
   245     CProfileImpl* profile = NULL;
   241 
   246 
   242     iMutex.Wait();
   247     iMutex.Wait();
   243     TInt err( CheckProfileIdL( aId ) );
   248     TInt err( CheckProfileIdL( aId ) );
   244 
   249 
   278             SetLocalizedNameForDynamicProfileL( *profile );
   283             SetLocalizedNameForDynamicProfileL( *profile );
   279             }
   284             }
   280         }
   285         }
   281 
   286 
   282     return profile;
   287     return profile;
       
   288     */
   283     }
   289     }
   284 
   290 
   285 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   286 // CProfileEngineImpl::ProfileL
   292 // CProfileEngineImpl::ProfileL
   287 //
   293 //
   289 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   290 //
   296 //
   291 MProfileExtended* CProfileEngineImpl::ProfileL(
   297 MProfileExtended* CProfileEngineImpl::ProfileL(
   292     TInt aId )
   298     TInt aId )
   293     {
   299     {
       
   300     return Profile2L( aId );
       
   301     /*
   294     MProfileExtended* profile = ProfileLC( aId );
   302     MProfileExtended* profile = ProfileLC( aId );
   295     CleanupStack::Pop();    // profile
   303     CleanupStack::Pop();    // profile
   296     return profile;
   304     return profile;
       
   305     */
   297     }
   306     }
   298 
   307 
   299 
   308 
   300 // -----------------------------------------------------------------------------
   309 // -----------------------------------------------------------------------------
   301 // CProfileEngineImpl::SetActiveProfileL
   310 // CProfileEngineImpl::SetActiveProfileL
   568            iCenRep->CleanupCancelTransactionPushL();
   577            iCenRep->CleanupCancelTransactionPushL();
   569            aProfile.ExternalizeL( *iCenRep );
   578            aProfile.ExternalizeL( *iCenRep );
   570 
   579 
   571            if( profileId == activeId )
   580            if( profileId == activeId )
   572                {
   581                {
   573                UpdateActiveProfileSettingsL( aProfile );
   582                MProfileExtended2 *activeProfile = Profile2LC(activeId);
       
   583                UpdateActiveProfileSettingsL( *activeProfile );
       
   584                CleanupStack::PopAndDestroy(); // activeProfile
   574                }
   585                }
   575 
   586 
   576            // write settings to Cenrep:
   587            // write settings to Cenrep:
   577            User::LeaveIfError( iCenRep->CommitTransaction( ignore ) );
   588            User::LeaveIfError( iCenRep->CommitTransaction( ignore ) );
   578            CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   589            CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL()
   624 // CProfileEngineImpl::UpdateActiveProfileSettingsL
   635 // CProfileEngineImpl::UpdateActiveProfileSettingsL
   625 //
   636 //
   626 // (other items were commented in a header).
   637 // (other items were commented in a header).
   627 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   628 //
   639 //
   629 void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfile& aProfile,
   640 void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfileExtended2& aProfile,
   630         TBool aSetId )
   641         TBool aSetId )
   631     {
   642     {
   632     const MProfileTones& profileTones = aProfile.ProfileTones();
   643     const MProfileTones& profileTones = aProfile.ProfileTones();
       
   644     const MProfileExtraTones2& profileExtraTones = aProfile.ProfileExtraTones2();
   633     const MProfileName& profileName = aProfile.ProfileName();
   645     const MProfileName& profileName = aProfile.ProfileName();
   634     const TProfileToneSettings& settings = profileTones.ToneSettings();
   646     const TProfileToneSettings& settings = profileTones.ToneSettings();
       
   647    // const MProfileVibraSettings &vibraSettings = aProfile.ProfileVibraSettings();
   635 
   648 
   636     // These cannot fail because this method is called only in between
   649     // These cannot fail because this method is called only in between
   637     // StartTransaction() and CommitTransaction() calls (except vibra)
   650     // StartTransaction() and CommitTransaction() calls (except vibra)
   638     iCenRep->Set( KProEngActiveRingingType, settings.iRingingType );
   651     iCenRep->Set( KProEngActiveRingingType, settings.iRingingType );
   639     iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume );
   652    
       
   653     //Removed. only master volue used
       
   654     // iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume );
   640     iCenRep->Set( KProEngActiveMessageAlert, !( aProfile.IsSilent() ) );
   655     iCenRep->Set( KProEngActiveMessageAlert, !( aProfile.IsSilent() ) );
       
   656     
       
   657     //Since 10.1
       
   658     iCenRep->Set( KProEngActiveRingTone,profileTones.RingingTone1() );
       
   659     iCenRep->Set( KProEngActiveMessageTone,profileTones.MessageAlertTone() );
       
   660     iCenRep->Set( KProEngActiveReminderTone,profileExtraTones.ReminderTone() );
       
   661     iCenRep->Set( KProEngActiveClockAlarmTone,profileExtraTones.ClockAlarmTone() );
       
   662     
       
   663     /*
       
   664     if ( MasterVibraL() )
       
   665         {
       
   666         iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() );
       
   667         }
       
   668     else
       
   669         {
       
   670         iCenRep->Set( KProEngActiveAlertVibra,0 );
       
   671         }
       
   672     */
       
   673     
   641     if ( !PowerSaveMode() )
   674     if ( !PowerSaveMode() )
   642         {
   675         {
   643     User::LeaveIfError( iVibraCenRep->Set(
   676     User::LeaveIfError( iVibraCenRep->Set(
   644             KVibraCtrlProfileVibraEnabled, settings.iVibratingAlert ) );
   677             KVibraCtrlProfileVibraEnabled, /*vibraSettings.AlertVibra() != 0 &&*/ MasterVibraL() ) );
   645 
   678 
   646 #ifdef RD_TACTILE_FEEDBACK
   679 #ifdef RD_TACTILE_FEEDBACK
   647 	const MProfileExtraSettings& extraSettings = aProfile.ProfileExtraSettings();
   680 	const MProfileExtraSettings& extraSettings = aProfile.ProfileExtraSettings();
   648 	const MProfileFeedbackSettings& feedbackSettings = 
   681 	const MProfileFeedbackSettings& feedbackSettings = 
   649 			extraSettings.ProfileFeedbackSettings();
   682 			extraSettings.ProfileFeedbackSettings();
   718 
   751 
   719         User::LeaveIfError( aProfilesNames->InsertInOrder( nameImpl ) );
   752         User::LeaveIfError( aProfilesNames->InsertInOrder( nameImpl ) );
   720         CleanupStack::Pop();    // nameImpl
   753         CleanupStack::Pop();    // nameImpl
   721         }
   754         }
   722 
   755 
   723     ReadDynamicProfilesNamesL( aProfilesNames, *profileName );
   756     // Since 10.1, No dynamic profiles in TB 10.1
       
   757  //   ReadDynamicProfilesNamesL( aProfilesNames, *profileName );
   724     CleanupStack::PopAndDestroy();  // profileName
   758     CleanupStack::PopAndDestroy();  // profileName
   725     }
   759     }
   726 
   760 
   727 // -----------------------------------------------------------------------------
   761 // -----------------------------------------------------------------------------
   728 // CProfileEngineImpl::DoSetActiveProfileL
   762 // CProfileEngineImpl::DoSetActiveProfileL
   731 // -----------------------------------------------------------------------------
   765 // -----------------------------------------------------------------------------
   732 //
   766 //
   733 void CProfileEngineImpl::DoSetActiveProfileL(
   767 void CProfileEngineImpl::DoSetActiveProfileL(
   734     TInt aId, TTime* aTime )
   768     TInt aId, TTime* aTime )
   735     {
   769     {
   736     MProfileExtended* profile = ProfileLC( aId );
   770     MProfileExtended2* profile = Profile2LC( aId );
   737 
   771 
   738     User::LeaveIfError( iCenRep->StartTransaction(
   772     User::LeaveIfError( iCenRep->StartTransaction(
   739             CRepository::EReadWriteTransaction ) );
   773             CRepository::EReadWriteTransaction ) );
   740     iCenRep->CleanupCancelTransactionPushL();
   774     iCenRep->CleanupCancelTransactionPushL();
   741     // Cancel first any pending timings (the logic is the same both in new
   775     // Cancel first any pending timings (the logic is the same both in new
   936     {
   970     {
   937     return CProfileEngineImpl::NewL();
   971     return CProfileEngineImpl::NewL();
   938     }
   972     }
   939 
   973 
   940 // -----------------------------------------------------------------------------
   974 // -----------------------------------------------------------------------------
       
   975 // CreateProfileEngineExtendedL create profiles engine and
       
   976 // return internal interface of the profiles engine
       
   977 // Returns: Profiles Engine internal interface
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L()
       
   981     {
       
   982     return CProfileEngineImpl::NewL();
       
   983     }
       
   984 
       
   985 // -----------------------------------------------------------------------------
   941 // CreateProfileEngineL create profiles engine and return public interface
   986 // CreateProfileEngineL create profiles engine and return public interface
   942 // of the profiles engine.
   987 // of the profiles engine.
   943 // Returns: Profiles Engine public interface
   988 // Returns: Profiles Engine public interface
   944 // -----------------------------------------------------------------------------
   989 // -----------------------------------------------------------------------------
   945 //
   990 //
   957 EXPORT_C MProfileEngineExtended* CreateProfileEngineExtendedL( RFs* aFs )
  1002 EXPORT_C MProfileEngineExtended* CreateProfileEngineExtendedL( RFs* aFs )
   958     {
  1003     {
   959     return CProfileEngineImpl::NewL( aFs );
  1004     return CProfileEngineImpl::NewL( aFs );
   960     }
  1005     }
   961 
  1006 
       
  1007 // -----------------------------------------------------------------------------
       
  1008 // CreateProfileEngineExtendedL create profiles engine and
       
  1009 // return internal interface of the profiles engine
       
  1010 // Returns: Profiles Engine internal interface
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L( RFs* aFs )
       
  1014     {
       
  1015     return CProfileEngineImpl::NewL( aFs );
       
  1016     }
   962 
  1017 
   963 // -----------------------------------------------------------------------------
  1018 // -----------------------------------------------------------------------------
   964 // CProfileEngineImpl::PowerSaveMode
  1019 // CProfileEngineImpl::PowerSaveMode
   965 //
  1020 //
   966 // -----------------------------------------------------------------------------
  1021 // -----------------------------------------------------------------------------
  1011         
  1066         
  1012     return EFalse;
  1067     return EFalse;
  1013     }
  1068     }
  1014 
  1069 
  1015 
  1070 
       
  1071 
       
  1072 // -----------------------------------------------------------------------------
       
  1073 // CProfileEngineImpl::Profile2LC
       
  1074 //
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //
       
  1077 MProfileExtended2* CProfileEngineImpl::Profile2LC( TInt aId )
       
  1078     {
       
  1079     CProfileImpl* profile = NULL;
       
  1080 
       
  1081     iMutex.Wait();
       
  1082     TInt err( CheckProfileIdL( aId ) );
       
  1083 
       
  1084     if( !err )
       
  1085         {
       
  1086         TRAP( err, profile = GetProfileL( aId ) );
       
  1087         }
       
  1088     iMutex.Signal();
       
  1089 
       
  1090     User::LeaveIfError( err );
       
  1091 
       
  1092     CleanupStack::PushL( profile );
       
  1093 
       
  1094     if( iSideVolumeKeys )
       
  1095         {
       
  1096         // Because SetTemp*VolumeL() functions update only Shared Data those
       
  1097         // values must be read from SD and set to the MProfile instance
       
  1098         // returned to the caller:
       
  1099         TInt activeId( User::LeaveIfError( ActiveProfileId() ) );
       
  1100         if( activeId == aId )
       
  1101             {
       
  1102             TProfileToneSettings& settings =
       
  1103                     profile->ProfileSetTones().SetToneSettings();
       
  1104             settings.iRingingVolume = TempRingingVolumeL();
       
  1105             settings.iMediaVolume = TempMediaVolumeL();
       
  1106             }
       
  1107         }
       
  1108 
       
  1109     if( !profile->IsProfileNameChanged() )
       
  1110         {
       
  1111         if( IsDefaultProfile( aId ) )
       
  1112             {
       
  1113             profile->SetLocalizedProfileNameL( *iProfileLocalisedNames );
       
  1114             }
       
  1115         else
       
  1116             {
       
  1117             SetLocalizedNameForDynamicProfileL( *profile );
       
  1118             }
       
  1119         }
       
  1120 
       
  1121     return profile;
       
  1122     }
       
  1123 
       
  1124 // -----------------------------------------------------------------------------
       
  1125 // CProfileEngineImpl::Profile2L
       
  1126 //
       
  1127 // -----------------------------------------------------------------------------
       
  1128 //
       
  1129 MProfileExtended2* CProfileEngineImpl::Profile2L( TInt aId )
       
  1130     {
       
  1131     MProfileExtended2* profile = Profile2LC( aId );
       
  1132     CleanupStack::Pop();    // profile
       
  1133     return profile;
       
  1134     }
       
  1135 
       
  1136 // -----------------------------------------------------------------------------
       
  1137 // CProfileEngineImpl::CommitChange2L
       
  1138 //
       
  1139 // -----------------------------------------------------------------------------
       
  1140 //
       
  1141 void CProfileEngineImpl::CommitChange2L( MProfileExtended2& aProfile )
       
  1142     {
       
  1143     CommitChangeL (aProfile);
       
  1144     }
       
  1145 
       
  1146 
       
  1147 // -----------------------------------------------------------------------------
       
  1148 // CProfileEngineImpl::MasterVolumeL
       
  1149 //
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 TInt CProfileEngineImpl::MasterVolumeL() const
       
  1153     {
       
  1154     TInt masterVolume( 0 );
       
  1155     User::LeaveIfError( iCenRep->Get( KProEngMasterVolume, masterVolume ) );
       
  1156     return masterVolume;
       
  1157     }
       
  1158 
       
  1159 // -----------------------------------------------------------------------------
       
  1160 // CProfileEngineImpl::SetMasterVolumeL
       
  1161 //
       
  1162 // -----------------------------------------------------------------------------
       
  1163 //
       
  1164 void CProfileEngineImpl::SetMasterVolumeL( TInt aMasterVolume )
       
  1165     {
       
  1166     User::LeaveIfError( iCenRep->Set( KProEngMasterVolume, aMasterVolume ) );
       
  1167     User::LeaveIfError( iCenRep->Set( KProEngActiveRingingVolume, aMasterVolume ) );
       
  1168     
       
  1169     //Send event through P&S
       
  1170     CreatePubSubKeysIfNeededL();
       
  1171     PublishChangeL( KProEngActiveProfileModified );
       
  1172     }
       
  1173 
       
  1174 // -----------------------------------------------------------------------------
       
  1175 // CProfileEngineImpl::MasterVibraL
       
  1176 //
       
  1177 // -----------------------------------------------------------------------------
       
  1178 //
       
  1179 TBool CProfileEngineImpl::MasterVibraL() const
       
  1180     {
       
  1181     TInt masterVibra( 0 );
       
  1182     User::LeaveIfError( iCenRep->Get( KProEngMasterVibra, masterVibra ) );
       
  1183     return ( masterVibra != 0 );
       
  1184     }
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // CProfileEngineImpl::SetMasterVibraL
       
  1188 //
       
  1189 // -----------------------------------------------------------------------------
       
  1190 //
       
  1191 void CProfileEngineImpl::SetMasterVibraL( TBool aMasterVibra )
       
  1192     {
       
  1193     User::LeaveIfError( iCenRep->Set( KProEngMasterVibra, aMasterVibra ? 1 : 0 ) );
       
  1194     User::LeaveIfError ( iCenRep->Set( KProEngActiveAlertVibra, aMasterVibra ? 1 : 0 ) );
       
  1195     
       
  1196     /*
       
  1197     MProfileExtended2* activeProfile = Profile2LC( ActiveProfileId() );
       
  1198     const MProfileVibraSettings &vibraSettings = activeProfile->ProfileVibraSettings();
       
  1199     if (activeProfile)
       
  1200         {
       
  1201         if (aMasterVibra)
       
  1202             {
       
  1203             iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() );
       
  1204             }
       
  1205         else
       
  1206             {
       
  1207             iCenRep->Set( KProEngActiveAlertVibra, 0 );
       
  1208             }        
       
  1209         }
       
  1210     CleanupStack::PopAndDestroy(); // activeProfile
       
  1211     */
       
  1212             
       
  1213     if ( !PowerSaveMode() )
       
  1214         {
       
  1215         User::LeaveIfError( iVibraCenRep->Set(
       
  1216                 KVibraCtrlProfileVibraEnabled, aMasterVibra ? 1 : 0) );
       
  1217         }
       
  1218     
       
  1219     //Send event through P&S
       
  1220     CreatePubSubKeysIfNeededL();
       
  1221     PublishChangeL( KProEngActiveProfileModified );
       
  1222     }
       
  1223 
       
  1224 // -----------------------------------------------------------------------------
       
  1225 // CProfileEngineImpl::SilenceModeL
       
  1226 //
       
  1227 // -----------------------------------------------------------------------------
       
  1228 //
       
  1229 TBool CProfileEngineImpl::SilenceModeL() const
       
  1230     {
       
  1231     TInt silenceMode( 0 );
       
  1232     User::LeaveIfError( iCenRep->Get( KProEngSilenceMode, silenceMode ) );
       
  1233     return ( silenceMode != 0 );
       
  1234     }
       
  1235 
       
  1236 // -----------------------------------------------------------------------------
       
  1237 // CProfileEngineImpl::SetSilenceModeL
       
  1238 //
       
  1239 // -----------------------------------------------------------------------------
       
  1240 //
       
  1241 void CProfileEngineImpl::SetSilenceModeL( TBool aSilenceMode )
       
  1242     {
       
  1243     User::LeaveIfError( iCenRep->Set( KProEngSilenceMode, aSilenceMode ? 1 : 0 ) );
       
  1244     }
       
  1245 
  1016 //  End of File
  1246 //  End of File