diff -r 8bda91a87a00 -r 8ee96d21d9bf profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp --- a/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp Thu Aug 19 10:12:30 2010 +0300 +++ b/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp Tue Aug 31 15:29:50 2010 +0300 @@ -19,6 +19,14 @@ // INCLUDE FILES #include "CProfileEngineImpl.h" +#include "CProfilesNamesArrayImpl.h" +#include "CProfileImpl.h" +#include "CProfileNameImpl.h" +#include "ProfileEngUtils.h" +#include "ProfileEngPanic.h" +#include "CProfileTiming.h" +#include "ProfileEnginePrivateCRKeys.h" +#include "ProfilesDebug.h" #include // BaflUtils #include // RResoureFile #include @@ -26,35 +34,30 @@ #include #include -#include +#include #include #include -#include "CProfilesNamesArrayImpl.h" -#include "CProfileImpl.h" -#include "CProfileNameImpl.h" -#include "ProfileEngUtils.h" #include #include #include -#include "ProfileEngPanic.h" #include #include -#include "MProfileExtraSettings.h" -#include "MProfileFeedbackSettings.h" +#include +#include #include #include -#include "ProfilesVariant.hrh" // KProEngFeatureIdVTRingingTone -#include "CProfileTiming.h" +#include // KProEngFeatureIdVTRingingTone #include -#include "ProfileEnginePrivateCRKeys.h" #include #include #include -#include "ProfilesDebug.h" #include #include +#include +#include + // ============================ MEMBER FUNCTIONS =============================== @@ -237,6 +240,8 @@ MProfileExtended* CProfileEngineImpl::ProfileLC( TInt aId ) { + return Profile2LC( aId ); + /* CProfileImpl* profile = NULL; iMutex.Wait(); @@ -280,6 +285,7 @@ } return profile; + */ } // ----------------------------------------------------------------------------- @@ -291,9 +297,12 @@ MProfileExtended* CProfileEngineImpl::ProfileL( TInt aId ) { + return Profile2L( aId ); + /* MProfileExtended* profile = ProfileLC( aId ); CleanupStack::Pop(); // profile return profile; + */ } @@ -310,6 +319,7 @@ iMutex.Wait(); TInt err( CheckProfileIdL( aId ) ); + if( !err ) { TRAP( err, DoSetActiveProfileL( aId ) ); @@ -569,7 +579,9 @@ if( profileId == activeId ) { - UpdateActiveProfileSettingsL( aProfile ); + MProfileExtended2 *activeProfile = Profile2LC(activeId); + UpdateActiveProfileSettingsL( *activeProfile ); + CleanupStack::PopAndDestroy(); // activeProfile } // write settings to Cenrep: @@ -625,22 +637,44 @@ // (other items were commented in a header). // ----------------------------------------------------------------------------- // -void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfile& aProfile, +void CProfileEngineImpl::UpdateActiveProfileSettingsL( MProfileExtended2& aProfile, TBool aSetId ) { const MProfileTones& profileTones = aProfile.ProfileTones(); + const MProfileExtraTones2& profileExtraTones = aProfile.ProfileExtraTones2(); const MProfileName& profileName = aProfile.ProfileName(); const TProfileToneSettings& settings = profileTones.ToneSettings(); + // const MProfileVibraSettings &vibraSettings = aProfile.ProfileVibraSettings(); // These cannot fail because this method is called only in between // StartTransaction() and CommitTransaction() calls (except vibra) iCenRep->Set( KProEngActiveRingingType, settings.iRingingType ); - iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume ); + + //Removed. only master volue used + // iCenRep->Set( KProEngActiveRingingVolume, settings.iRingingVolume ); iCenRep->Set( KProEngActiveMessageAlert, !( aProfile.IsSilent() ) ); + + //Since 10.1 + iCenRep->Set( KProEngActiveRingTone,profileTones.RingingTone1() ); + iCenRep->Set( KProEngActiveMessageTone,profileTones.MessageAlertTone() ); + iCenRep->Set( KProEngActiveReminderTone,profileExtraTones.ReminderTone() ); + iCenRep->Set( KProEngActiveClockAlarmTone,profileExtraTones.ClockAlarmTone() ); + + /* + if ( MasterVibraL() ) + { + iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() ); + } + else + { + iCenRep->Set( KProEngActiveAlertVibra,0 ); + } + */ + if ( !PowerSaveMode() ) { User::LeaveIfError( iVibraCenRep->Set( - KVibraCtrlProfileVibraEnabled, settings.iVibratingAlert ) ); + KVibraCtrlProfileVibraEnabled, /*vibraSettings.AlertVibra() != 0 &&*/ MasterVibraL() ) ); #ifdef RD_TACTILE_FEEDBACK const MProfileExtraSettings& extraSettings = aProfile.ProfileExtraSettings(); @@ -719,7 +753,8 @@ CleanupStack::Pop(); // nameImpl } - ReadDynamicProfilesNamesL( aProfilesNames, *profileName ); + // Since 10.1, No dynamic profiles in TB 10.1 + // ReadDynamicProfilesNamesL( aProfilesNames, *profileName ); CleanupStack::PopAndDestroy(); // profileName } @@ -732,7 +767,7 @@ void CProfileEngineImpl::DoSetActiveProfileL( TInt aId, TTime* aTime ) { - MProfileExtended* profile = ProfileLC( aId ); + MProfileExtended2* profile = Profile2LC( aId ); User::LeaveIfError( iCenRep->StartTransaction( CRepository::EReadWriteTransaction ) ); @@ -937,6 +972,17 @@ } // ----------------------------------------------------------------------------- +// CreateProfileEngineExtendedL create profiles engine and +// return internal interface of the profiles engine +// Returns: Profiles Engine internal interface +// ----------------------------------------------------------------------------- +// +EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L() + { + return CProfileEngineImpl::NewL(); + } + +// ----------------------------------------------------------------------------- // CreateProfileEngineL create profiles engine and return public interface // of the profiles engine. // Returns: Profiles Engine public interface @@ -958,6 +1004,16 @@ return CProfileEngineImpl::NewL( aFs ); } +// ----------------------------------------------------------------------------- +// CreateProfileEngineExtendedL create profiles engine and +// return internal interface of the profiles engine +// Returns: Profiles Engine internal interface +// ----------------------------------------------------------------------------- +// +EXPORT_C MProfileEngineExtended2* CreateProfileEngineExtended2L( RFs* aFs ) + { + return CProfileEngineImpl::NewL( aFs ); + } // ----------------------------------------------------------------------------- // CProfileEngineImpl::PowerSaveMode @@ -1012,4 +1068,183 @@ } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::Profile2LC +// +// ----------------------------------------------------------------------------- +// +MProfileExtended2* CProfileEngineImpl::Profile2LC( TInt aId ) + { + CProfileImpl* profile = NULL; + + iMutex.Wait(); + TInt err( CheckProfileIdL( aId ) ); + + if( !err ) + { + TRAP( err, profile = GetProfileL( aId ) ); + } + iMutex.Signal(); + + User::LeaveIfError( err ); + + CleanupStack::PushL( profile ); + + if( iSideVolumeKeys ) + { + // Because SetTemp*VolumeL() functions update only Shared Data those + // values must be read from SD and set to the MProfile instance + // returned to the caller: + TInt activeId( User::LeaveIfError( ActiveProfileId() ) ); + if( activeId == aId ) + { + TProfileToneSettings& settings = + profile->ProfileSetTones().SetToneSettings(); + settings.iRingingVolume = TempRingingVolumeL(); + settings.iMediaVolume = TempMediaVolumeL(); + } + } + + if( !profile->IsProfileNameChanged() ) + { + if( IsDefaultProfile( aId ) ) + { + profile->SetLocalizedProfileNameL( *iProfileLocalisedNames ); + } + else + { + SetLocalizedNameForDynamicProfileL( *profile ); + } + } + + return profile; + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::Profile2L +// +// ----------------------------------------------------------------------------- +// +MProfileExtended2* CProfileEngineImpl::Profile2L( TInt aId ) + { + MProfileExtended2* profile = Profile2LC( aId ); + CleanupStack::Pop(); // profile + return profile; + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::CommitChange2L +// +// ----------------------------------------------------------------------------- +// +void CProfileEngineImpl::CommitChange2L( MProfileExtended2& aProfile ) + { + CommitChangeL (aProfile); + } + + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::MasterVolumeL +// +// ----------------------------------------------------------------------------- +// +TInt CProfileEngineImpl::MasterVolumeL() const + { + TInt masterVolume( 0 ); + User::LeaveIfError( iCenRep->Get( KProEngMasterVolume, masterVolume ) ); + return masterVolume; + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::SetMasterVolumeL +// +// ----------------------------------------------------------------------------- +// +void CProfileEngineImpl::SetMasterVolumeL( TInt aMasterVolume ) + { + User::LeaveIfError( iCenRep->Set( KProEngMasterVolume, aMasterVolume ) ); + User::LeaveIfError( iCenRep->Set( KProEngActiveRingingVolume, aMasterVolume ) ); + + //Send event through P&S + CreatePubSubKeysIfNeededL(); + PublishChangeL( KProEngActiveProfileModified ); + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::MasterVibraL +// +// ----------------------------------------------------------------------------- +// +TBool CProfileEngineImpl::MasterVibraL() const + { + TInt masterVibra( 0 ); + User::LeaveIfError( iCenRep->Get( KProEngMasterVibra, masterVibra ) ); + return ( masterVibra != 0 ); + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::SetMasterVibraL +// +// ----------------------------------------------------------------------------- +// +void CProfileEngineImpl::SetMasterVibraL( TBool aMasterVibra ) + { + User::LeaveIfError( iCenRep->Set( KProEngMasterVibra, aMasterVibra ? 1 : 0 ) ); + User::LeaveIfError ( iCenRep->Set( KProEngActiveAlertVibra, aMasterVibra ? 1 : 0 ) ); + + /* + MProfileExtended2* activeProfile = Profile2LC( ActiveProfileId() ); + const MProfileVibraSettings &vibraSettings = activeProfile->ProfileVibraSettings(); + if (activeProfile) + { + if (aMasterVibra) + { + iCenRep->Set( KProEngActiveAlertVibra,vibraSettings.AlertVibra() ); + } + else + { + iCenRep->Set( KProEngActiveAlertVibra, 0 ); + } + } + CleanupStack::PopAndDestroy(); // activeProfile + */ + + if ( !PowerSaveMode() ) + { + User::LeaveIfError( iVibraCenRep->Set( + KVibraCtrlProfileVibraEnabled, aMasterVibra ? 1 : 0) ); + } + + //Send event through P&S + CreatePubSubKeysIfNeededL(); + PublishChangeL( KProEngActiveProfileModified ); + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::SilenceModeL +// +// ----------------------------------------------------------------------------- +// +TBool CProfileEngineImpl::SilenceModeL() const + { + TInt silenceMode( 0 ); + User::LeaveIfError( iCenRep->Get( KProEngSilenceMode, silenceMode ) ); + return ( silenceMode != 0 ); + } + +// ----------------------------------------------------------------------------- +// CProfileEngineImpl::SetSilenceModeL +// +// ----------------------------------------------------------------------------- +// +void CProfileEngineImpl::SetSilenceModeL( TBool aSilenceMode ) + { + User::LeaveIfError( iCenRep->Set( KProEngSilenceMode, aSilenceMode ? 1 : 0 ) ); + + //Send event through P&S + CreatePubSubKeysIfNeededL(); + PublishChangeL( KProEngActiveProfileModified ); + } + // End of File