profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
changeset 36 48848d132687
parent 32 20bd089f4aaa
child 23 7e4c5a2ff1a2
--- a/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp	Thu Apr 01 03:31:13 2010 +0800
+++ b/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp	Fri Apr 16 11:40:46 2010 +0800
@@ -55,6 +55,9 @@
 #include <psmsettings.h>
 #include <psmsrvdomaincrkeys.h>
 
+#include <MProfileExtraTones2.h>
+#include <MProfileVibraSettings.h>
+
 
 // ============================ 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;
+    */
     }
 
 
@@ -570,7 +579,9 @@
 
            if( profileId == activeId )
                {
-               UpdateActiveProfileSettingsL( aProfile );
+               MProfileExtended2 *activeProfile = Profile2LC(activeId);
+               UpdateActiveProfileSettingsL( *activeProfile );
+               CleanupStack::PopAndDestroy(); // activeProfile
                }
 
            // write settings to Cenrep:
@@ -626,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();
@@ -720,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
     }
 
@@ -733,7 +767,7 @@
 void CProfileEngineImpl::DoSetActiveProfileL(
     TInt aId, TTime* aTime )
     {
-    MProfileExtended* profile = ProfileLC( aId );
+    MProfileExtended2* profile = Profile2LC( aId );
 
     User::LeaveIfError( iCenRep->StartTransaction(
             CRepository::EReadWriteTransaction ) );
@@ -938,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
@@ -959,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
@@ -1013,4 +1068,179 @@
     }
 
 
+
+// -----------------------------------------------------------------------------
+// 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 ) );
+    }
+
 //  End of File