profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 17 3b47783fdf16
child 25 7e0eff37aedb
--- 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 <bautils.h> // BaflUtils
 #include <barsc.h> // RResoureFile
 #include <featmgr.h>
@@ -26,35 +34,30 @@
 #include <DRMCommon.h>
 #include <sysutil.h>
 
-#include <profileeng.rsg>
+#include <ProfileEng.rsg>
 #include <TProfileToneSettings.h>
 #include <MProfileTones.h>
-#include "CProfilesNamesArrayImpl.h"
-#include "CProfileImpl.h"
-#include "CProfileNameImpl.h"
-#include "ProfileEngUtils.h"
 #include <MProfileSetName.h>
 #include <ProfileEng.hrh>
 #include <ProfileEngineConstants.h>
-#include "ProfileEngPanic.h"
 #include <MProfileSetTones.h>
 #include <MProfileSetExtraTones.h>
-#include "MProfileExtraSettings.h"
-#include "MProfileFeedbackSettings.h"
+#include <MProfileExtraSettings.h>
+#include <MProfileFeedbackSettings.h>
 #include <MProfilesLocalFeatures.h>
 #include <MProfileUtilitySingleton.h>
-#include "ProfilesVariant.hrh" // KProEngFeatureIdVTRingingTone
-#include "CProfileTiming.h"
+#include <ProfilesVariant.hrh> // KProEngFeatureIdVTRingingTone
 #include <centralrepository.h>
-#include "ProfileEnginePrivateCRKeys.h"
 #include <ProfileEnginePrivatePSKeys.h>
 #include <hwrmvibrasdkcrkeys.h>
 #include <data_caging_path_literals.hrh>
-#include "ProfilesDebug.h"
 
 #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;
+    */
     }
 
 
@@ -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