phoneengine/phonemodel/src/cpeprofilesettingmonitor.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
    21 #include "cpeprofilesettingmonitor.h"
    21 #include "cpeprofilesettingmonitor.h"
    22 #include "mpephonemodelinternal.h"
    22 #include "mpephonemodelinternal.h"
    23 #include <mpedatastore.h>
    23 #include <mpedatastore.h>
    24 #include <MProfileExtraTones.h>
    24 #include <MProfileExtraTones.h>
    25 #include <talogger.h>
    25 #include <talogger.h>
    26 #include <ProfileEngineInternalCRKeys.h>
       
    27 
    26 
    28 
    27 
    29 /////////////////////////////////////////////////////////////////////////
    28 /////////////////////////////////////////////////////////////////////////
    30 // CPEProfileSettingMonitor
    29 // CPEProfileSettingMonitor
    31 /////////////////////////////////////////////////////////////////////////
    30 /////////////////////////////////////////////////////////////////////////
    62 // might leave.
    61 // might leave.
    63 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    64 //
    63 //
    65 CPEProfileSettingMonitor::CPEProfileSettingMonitor(
    64 CPEProfileSettingMonitor::CPEProfileSettingMonitor(
    66         MPEPhoneModelInternal& aModel
    65         MPEPhoneModelInternal& aModel
    67         ) : CPECenRepMonitor( KProEngSilenceMode ), 
    66         ) : iModel( aModel )
    68             iModel( aModel )
       
    69     {
    67     {
    70     }
    68     }
    71 
    69 
    72 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    73 // CPEProfileSettingMonitor::ConstructL
    71 // CPEProfileSettingMonitor::ConstructL
    78     {
    76     {
    79     // Create the profile engine
    77     // Create the profile engine
    80     iProfileEngine = CreateProfileEngineL();
    78     iProfileEngine = CreateProfileEngineL();
    81     
    79     
    82     // Retrieve current profile settings    
    80     // Retrieve current profile settings    
    83 
    81     GetProfileSettingsL();
    84     BaseConstructL( KCRUidProfileEngine );
       
    85     
    82     
    86     iModel.SendMessage( MEngineMonitor::EPEMessageProfileChanged ); 
    83     iModel.SendMessage( MEngineMonitor::EPEMessageProfileChanged ); 
    87     
    84     
    88     // Start listening for profiles change notifications
    85     // Start listening for profiles change notifications
    89     iProfileEventHandler = CProfileChangeNotifyHandler::NewL( this );    
    86     iProfileEventHandler = CProfileChangeNotifyHandler::NewL( this );    
   122             extraTones.VideoCallRingingTone() );
   119             extraTones.VideoCallRingingTone() );
   123         }
   120         }
   124     const TProfileToneSettings& toneSettings = activeTones.ToneSettings();  
   121     const TProfileToneSettings& toneSettings = activeTones.ToneSettings();  
   125     
   122     
   126     // Get ringing type and volume and keypad volume
   123     // Get ringing type and volume and keypad volume
   127     TProfileRingingType ringingType = toneSettings.iRingingType;
   124     TProfileRingingType ringingType = toneSettings.iRingingType;    
   128     
   125     iModel.DataStore()->SetRingingType( static_cast<TProfileRingingType>( ringingType ) );
   129     TInt silentVolume(0);
       
   130     if ( KErrNone == Get(silentVolume) && silentVolume )
       
   131         {
       
   132         iModel.DataStore()->SetRingingType(EProfileRingingTypeSilent);
       
   133         }
       
   134     else 
       
   135         {
       
   136         iModel.DataStore()->SetRingingType( static_cast<TProfileRingingType>( ringingType ) );
       
   137         }
       
   138     
       
   139     iModel.DataStore()->SetRingingVolume( toneSettings.iRingingVolume );
   126     iModel.DataStore()->SetRingingVolume( toneSettings.iRingingVolume );
   140     iModel.DataStore()->SetTextToSpeech( toneSettings.iTextToSpeech );
   127     iModel.DataStore()->SetTextToSpeech( toneSettings.iTextToSpeech );
   141                   
   128                   
   142     TProfileKeypadVolume keypadVolume = toneSettings.iKeypadVolume;
   129     TProfileKeypadVolume keypadVolume = toneSettings.iKeypadVolume;
   143         
   130     	
   144     if ( keypadVolume < EProfileKeypadVolumeOff 
   131     if ( keypadVolume < EProfileKeypadVolumeOff 
   145         || keypadVolume > EProfileKeypadVolumeLevel3 )
   132         || keypadVolume > EProfileKeypadVolumeLevel3 )
   146         {
   133 	    {
   147         // Value is out of range - use default
   134         // Value is out of range - use default
   148         keypadVolume = EProfileKeypadVolumeLevel2; // default value
   135 		keypadVolume = EProfileKeypadVolumeLevel2; // default value
   149         }
   136 	    }
   150     
   137 	
   151     const TInt KKeypadVolume[4] = {0, 2, 5, 10}; // Previous PE settings
   138 	const TInt KKeypadVolume[4] = {0, 2, 5, 10}; // Previous PE settings
   152     TInt volume = KKeypadVolume[ keypadVolume ];
   139 	TInt volume = KKeypadVolume[ keypadVolume ];
   153     iModel.DataStore()->SetKeypadVolume( volume );
   140 	iModel.DataStore()->SetKeypadVolume( volume );
   154 
   141 
   155     //  Get alert for group Ids
   142     //  Get alert for group Ids
   156     iModel.DataStore()->SetAlertForGroup( activeProfile->AlertForL() );
   143     iModel.DataStore()->SetAlertForGroup( activeProfile->AlertForL() );
   157 
   144 
   158     // Pop( activeProfile ) does not recognize ActiveProfileLC created 
   145     // Pop( activeProfile ) does not recognize ActiveProfileLC created 
   159     // item because of casting. However, functionality and cleanup works OK.
   146     // item because of casting. However, functionality and cleanup works OK.
   160     CleanupStack::Pop(); // activeProfile
   147     CleanupStack::Pop(); // activeProfile
   161     activeProfile->Release();
   148 	activeProfile->Release();
   162     __UHEAP_MARKEND;
   149 	__UHEAP_MARKEND;
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CPEProfileSettingMonitor::UpdateL
       
   167 // Callback function - implements virtual function from CPECenRepMonitor
       
   168 // This is called whenever cr settings change
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CPEProfileSettingMonitor::UpdateL()
       
   172     {
       
   173     TEFLOGSTRING( KTAINT, "PE CPEProfileSettingMonitor::UpdateL" );
       
   174     GetProfileSettingsL();
       
   175     iModel.SendMessage( MEngineMonitor::EPEMessageProfileChanged );
       
   176     }
   150     }
   177 
   151 
   178 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   179 // CPEProfileSettingMonitor::HandleActiveProfileEventL
   153 // CPEProfileSettingMonitor::HandleActiveProfileEventL
   180 // Callback function - implements virtual function from MProfileChangeObserver
   154 // Callback function - implements virtual function from MProfileChangeObserver