phoneengine/phonemodel/src/cpeexternaldatahandler.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include "penetworkhandler.h"
       
    22 #include "cpeexternaldatahandler.h"
    21 #include "cpeexternaldatahandler.h"
    23 #include "mpephonemodelinternal.h"
    22 #include "mpephonemodelinternal.h"
    24 #include <accessoriescrkeys.h>
    23 #include <accessoriescrkeys.h>
    25 #include <centralrepository.h>
    24 #include <centralrepository.h>
    26 #include <CoreApplicationUIsSDKCRKeys.h>
    25 #include <CoreApplicationUIsSDKCRKeys.h>
    30 #include <settingsinternalcrkeys.h>
    29 #include <settingsinternalcrkeys.h>
    31 #include <talogger.h>
    30 #include <talogger.h>
    32 #include <telephonyvariant.hrh>
    31 #include <telephonyvariant.hrh>
    33 #include <telinternalcrkeys.h>
    32 #include <telinternalcrkeys.h>
    34 
    33 
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KPrefixLength = 10;
       
    37 
    35 CPEExternalDataHandler* CPEExternalDataHandler::NewL( MPEPhoneModelInternal& aModel )
    38 CPEExternalDataHandler* CPEExternalDataHandler::NewL( MPEPhoneModelInternal& aModel )
    36     {
    39     {
    37     CPEExternalDataHandler* self = new ( ELeave ) CPEExternalDataHandler( *aModel.DataStore() );
    40     CPEExternalDataHandler* self = new ( ELeave ) CPEExternalDataHandler( *aModel.DataStore() );
    38     CleanupStack::PushL( self );
    41     CleanupStack::PushL( self );
    39     self->ConstructL( aModel );
    42     self->ConstructL( aModel );
    59     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::~CPEExternalDataHandler" );    
    62     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::~CPEExternalDataHandler" );    
    60 
    63 
    61     delete iTelephonyVariationRepository;
    64     delete iTelephonyVariationRepository;
    62     delete iTelephonySettingsRepository;
    65     delete iTelephonySettingsRepository;
    63     delete iProfileSettings;
    66     delete iProfileSettings;
    64     delete iNetworkRegistrationStatus;   
    67     delete iNetworkRegistrationStatus;
       
    68     delete iLoudspeakerVolumeSetting;
       
    69     delete iEarVolumeSetting;
    65     delete iCallDurationDisplay;
    70     delete iCallDurationDisplay;
    66     delete iAudioOutputPreferenceMonitor;
    71     delete iAudioOutputPreferenceMonitor;
    67     delete iAccessorySettingsRepository;
    72     delete iAccessorySettingsRepository;
    68     delete iAccessoryModeMonitor;
    73     delete iAccessoryModeMonitor;
    69     delete iCoreApplicationRepository;
    74     delete iCoreApplicationRepository;
    70     delete iNetworkHandler;
       
    71     }
    75     }
    72 
    76 
    73 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    74 // CPEExternalDataHandler::BaseConstructL
    78 // CPEExternalDataHandler::BaseConstructL
    75 // Symbian 2nd phase constructor can leave.
    79 // Symbian 2nd phase constructor can leave.
    79         MPEPhoneModelInternal& aModel )
    83         MPEPhoneModelInternal& aModel )
    80     {
    84     {
    81     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::BaseConstructL" );
    85     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::BaseConstructL" );
    82 
    86 
    83     // Instantiate monitor objects
    87     // Instantiate monitor objects
    84     iAudioOutputPreferenceMonitor = CPEAudioOutputPreferenceMonitor::NewL( aModel );    
    88     iAudioOutputPreferenceMonitor = CPEAudioOutputPreferenceMonitor::NewL( aModel );
    85     iCallDurationDisplay = CPECallDurationDisplaySettingMonitor::NewL(); 
    89     iCallDurationDisplay = CPECallDurationDisplaySettingMonitor::NewL();
       
    90     iEarVolumeSetting = CPEIncallEarVolumeSettingMonitor::NewL( aModel );
       
    91     iLoudspeakerVolumeSetting = CPEIncallLoudspeakerVolumeSettingMonitor::NewL( aModel );
       
    92     iNetworkRegistrationStatus = CPENetworkRegistrationStatusMonitor::NewL( aModel );
    86     iProfileSettings = CPEProfileSettingMonitor::NewL( aModel );
    93     iProfileSettings = CPEProfileSettingMonitor::NewL( aModel );
    87     
       
    88     iNetworkHandler = new PeNetworkHandler(aModel);
       
    89     //TODO
       
    90     /*
       
    91     iNetworkRegistrationStatus = CPENetworkRegistrationStatusMonitor::NewL( aModel );
       
    92     iAccessoryModeMonitor = CPEAccessoryModeMonitor::NewL(); 
    94     iAccessoryModeMonitor = CPEAccessoryModeMonitor::NewL(); 
    93 
    95 
    94     // Instantiate repository objects for later use
    96     // Instantiate repository objects for later use
    95     iAccessorySettingsRepository = CRepository::NewL( KCRUidAccessorySettings );*/
    97     iAccessorySettingsRepository = CRepository::NewL( KCRUidAccessorySettings );
    96     //iTelephonySettingsRepository = CRepository::NewL( KCRUidTelephonySettings );
    98     iTelephonySettingsRepository = CRepository::NewL( KCRUidTelephonySettings );
    97     iTelephonyVariationRepository = CRepository::NewL( KCRUidTelVariation );
    99     iTelephonyVariationRepository = CRepository::NewL( KCRUidTelVariation );
    98     iCoreApplicationRepository = CRepository::NewL( KCRUidCoreApplicationUIs ); 
   100     iCoreApplicationRepository = CRepository::NewL( KCRUidCoreApplicationUIs ); 
    99    
       
   100     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::BaseConstructL 2" );
       
   101     }
   101     }
   102 
   102 
   103 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   104 // CPEExternalDataHandler::Get
   104 // CPEExternalDataHandler::Get
   105 // Gets the current value of the specified setting, if the operation was successful
   105 // Gets the current value of the specified setting, if the operation was successful
   110         const TPEExternalDataId aSetting,
   110         const TPEExternalDataId aSetting,
   111         TInt& aValue ) const
   111         TInt& aValue ) const
   112     {
   112     {
   113     TInt errorCode( KErrNotFound );
   113     TInt errorCode( KErrNotFound );
   114 
   114 
   115     //TODO
   115     // Process Common id
   116 
   116     switch ( aSetting )
   117     if ( EPETelephonyVariationFlags == aSetting )
       
   118         {
   117         {
   119         errorCode = iTelephonyVariationRepository->Get( KTelVariationFlags, aValue );
   118         case EPEAutomaticAnswerHeadsetSetting:
   120         TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPETelephonyVariationFlags, error code: %d", errorCode );
   119             {
       
   120             errorCode = GetAutomaticAnswer( KSettingsHeadsetAutomaticAnswer, aValue );
       
   121             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAutomaticAnswerHeadsetSetting, error code: %d",errorCode );
       
   122             break;
       
   123             }        
       
   124         case EPEAutomaticAnswerLoopsetSetting:
       
   125             {
       
   126             errorCode = GetAutomaticAnswer( KSettingsLoopsetAutomaticAnswer, aValue );
       
   127             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAutomaticAnswerLoopsetSetting, error code: %d", errorCode );
       
   128             break;
       
   129             }        
       
   130         case EPEAutomaticAnswerCarkitSetting:
       
   131             {
       
   132             errorCode = GetAutomaticAnswer( KSettingsCarKitAutomaticAnswer, aValue );
       
   133             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAutomaticAnswerCarkitSetting, error code: %d", errorCode );
       
   134             break;
       
   135             }        
       
   136         case EPEAutomaticAnswerMusicStandSetting:
       
   137             {
       
   138             errorCode = GetAutomaticAnswer( KSettingsMusicStandAutomaticAnswer, aValue );
       
   139             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAutomaticAnswerMusicStandSetting, error code: %d", errorCode );
       
   140             break;
       
   141             }        
       
   142         case EPEAutomaticAnswerWirelessCarkitSetting:
       
   143             {
       
   144             errorCode = GetAutomaticAnswer( KSettingsWirelessCarkitAutomaticAnswer, aValue );
       
   145             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAutomaticAnswerWirelessCarkitSetting, error code: %d", errorCode );
       
   146             break;
       
   147             }
       
   148         case EPEAudioOutputPreference:
       
   149             {
       
   150             errorCode = iAudioOutputPreferenceMonitor->Get( aValue );
       
   151             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAudioOutputPreference, error code: %d", errorCode );
       
   152             break;
       
   153             }
       
   154         case EPECallDurationDisplaySetting:
       
   155             {
       
   156             errorCode = iCallDurationDisplay->Get( aValue );
       
   157             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPECallDurationDisplaySetting, error code: %d", errorCode );
       
   158             break;
       
   159             }
       
   160         case EPEDialPrefixChangeSetting:
       
   161             {
       
   162             errorCode = iTelephonySettingsRepository->Get( KSettingsDialPrefixChangeMode, aValue );
       
   163             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEDialPrefixChangeSetting, error code: %d", errorCode );
       
   164             break;
       
   165             }
       
   166         case EPEIncallEarVolumeSetting:
       
   167             {
       
   168             errorCode = iEarVolumeSetting->Get( aValue );
       
   169             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEIncallEarVolumeSetting, error code: %d", errorCode );
       
   170             break;
       
   171             }
       
   172         case EPEIncallLoudspeakerVolumeSetting:
       
   173             {
       
   174             errorCode = iLoudspeakerVolumeSetting->Get( aValue );
       
   175             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEIncallLoudspeakerVolumeSetting, error code: %d", errorCode );
       
   176             break;
       
   177             }
       
   178         case EPENetworkRegistrationStatus:
       
   179             {
       
   180             errorCode = iNetworkRegistrationStatus->Get( aValue );
       
   181             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPENetworkRegistrationStatus, error code: %d", errorCode );
       
   182             break;
       
   183             }
       
   184         case EPETelephonyVariationFlags:
       
   185             {
       
   186             errorCode = iTelephonyVariationRepository->Get( KTelVariationFlags, aValue );
       
   187             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPETelephonyVariationFlags, error code: %d", errorCode );
       
   188             break;
       
   189             }
       
   190         case EPEAccessoryMode:            
       
   191             {
       
   192             errorCode = KErrNone;
       
   193             aValue = iAccessoryModeMonitor->AccessoryMode();
       
   194             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAccessoryMode, error code: %d", errorCode );
       
   195             break;
       
   196             }
       
   197         case EPENetworkConnectionAllowedSetting:
       
   198             {
       
   199             // Fetches setting that indicates if network connection is allowed,
       
   200             // i.e. is the phone in off-line mode. This method is used while
       
   201             // attempting an emergency call, so no memory may be consumed.
       
   202             errorCode = iCoreApplicationRepository
       
   203                 ->Get( KCoreAppUIsNetworkConnectionAllowed, aValue );
       
   204             TEFLOGSTRING2( KTAINT, "CPEGsmExternalDataHandler::Get EPENetworkConnectionAllowedSetting, error code: %d",errorCode );
       
   205             break;
       
   206             }
       
   207         default:
       
   208             {
       
   209             TEFLOGSTRING2( KTAERROR, 
       
   210                 "PE CPEEXTERNALDATAHANDLER::GET UNKNOWN SETTING ID ! %d", aSetting );
       
   211             break;
       
   212             }
   121         }
   213         }
   122     else if ( EPEAudioOutputPreference == aSetting )
   214 
   123         {
       
   124         errorCode = iAudioOutputPreferenceMonitor->Get( aValue );
       
   125         TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPEAudioOutputPreference, error code: %d", errorCode );
       
   126         }    
       
   127     else if ( EPECallDurationDisplaySetting == aSetting )
       
   128         {
       
   129         errorCode = iCallDurationDisplay->Get( aValue );
       
   130         TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::Get EPECallDurationDisplaySetting, error code: %d", errorCode );
       
   131         }
       
   132     else if ( EPENetworkConnectionAllowedSetting == aSetting )
       
   133         {
       
   134         // Fetches setting that indicates if network connection is allowed,
       
   135         // i.e. is the phone in off-line mode. 
       
   136         errorCode = iCoreApplicationRepository
       
   137                 ->Get( KCoreAppUIsNetworkConnectionAllowed, aValue );
       
   138         }
       
   139     else
       
   140         {
       
   141         errorCode = KErrNone;
       
   142         aValue = 0;        
       
   143         }
       
   144 
       
   145     // Process Common id
       
   146     return errorCode;
   215     return errorCode;
   147     }
   216     }
   148 
   217 
   149 // -----------------------------------------------------------------------------
   218 // -----------------------------------------------------------------------------
   150 // CPEExternalDataHandler::Get
   219 // CPEExternalDataHandler::Get
   151 // Gets the current value of the specified setting, if the operation was successful
   220 // Gets the current value of the specified setting, if the operation was successful
   152 // aValue contains the current valid value of the setting
   221 // aValue contains the current valid value of the setting
   153 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   154 //
   223 //
   155 TInt CPEExternalDataHandler::GetText(
   224 TInt CPEExternalDataHandler::GetText(
   156         const TPEExternalDataId /*aSetting*/,
   225         const TPEExternalDataId aSetting,
   157         TDesC& aValue ) const
   226         TDesC& aValue ) const
   158     {
   227     {
   159     TInt errorCode( KErrNotFound );
   228     TInt errorCode( KErrNotFound );
   160     //TODO
   229 
   161     aValue = KNullDesC;
   230     // Process Common id
   162     errorCode = KErrNone;
   231     switch ( aSetting )
       
   232         {
       
   233         case EPEDialPrefixTextSetting:
       
   234             {
       
   235             TBuf<KPrefixLength> prefixTextSetting;
       
   236             
       
   237             errorCode = iTelephonySettingsRepository->Get( 
       
   238                 KSettingsDialPrefixText, 
       
   239                 prefixTextSetting );
       
   240                 
       
   241             aValue = prefixTextSetting;
       
   242             
       
   243             TEFLOGSTRING2( KTAINT, "CPEExternalDataHandler::GetText EPEDialPrefixTextSetting, error code: %d", errorCode );
       
   244             break;
       
   245             }
       
   246         default:
       
   247             {
       
   248             TEFLOGSTRING2( KTAERROR, 
       
   249                 "PE CPEEXTERNALDATAHANDLER::GETTEXT UNKNOWN SETTING ID ! %d", aSetting );
       
   250             break;
       
   251             }
       
   252         }
       
   253 
   163     return errorCode;
   254     return errorCode;
   164     }
   255     }
   165 
   256 
   166 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   167 // CPEExternalDataHandler::GetAutomaticAnswer
   258 // CPEExternalDataHandler::GetAutomaticAnswer
   168 // Check if automatic answer is defined for connected accessory.
   259 // Check if automatic answer is defined for connected accessory.
   169 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   170 //
   261 //
   171 TInt CPEExternalDataHandler::GetAutomaticAnswer(
   262 TInt CPEExternalDataHandler::GetAutomaticAnswer(
   172         TUint32 /*aSetting*/,
   263         TUint32 aSetting,
   173         TInt& aValue ) const
   264         TInt& aValue ) const
   174     {
   265     {
   175     TInt errorCode( KErrNotFound );
   266     TInt errorCode( KErrNotFound );
   176     
   267     
   177     TEFLOGSTRING( KTAINT, "CPEExternalDataHandler::GetAutomaticAnswer" );
   268     TEFLOGSTRING( KTAINT, "CPEExternalDataHandler::GetAutomaticAnswer" );
   178     errorCode = KErrNone;
   269    
   179     aValue = 0;
   270     errorCode = iAccessorySettingsRepository->Get( aSetting, aValue );
       
   271      
   180     return errorCode;
   272     return errorCode;
   181     }
   273     }
   182 
   274 
   183 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   184 // CPEExternalDataHandler::Set
   276 // CPEExternalDataHandler::Set
   191     {
   283     {
   192     TInt errorCode( KErrNotFound );
   284     TInt errorCode( KErrNotFound );
   193 
   285 
   194     switch ( aSetting )
   286     switch ( aSetting )
   195         {
   287         {
       
   288         case EPEIncallEarVolumeSetting:
       
   289             {
       
   290             errorCode = iEarVolumeSetting->Set( aValue );
       
   291             break;
       
   292             }
       
   293         case EPEIncallLoudspeakerVolumeSetting:
       
   294             {
       
   295             errorCode = iLoudspeakerVolumeSetting->Set( aValue );
       
   296             break;
       
   297             }
   196         case EPEEmergencyCallInfo:
   298         case EPEEmergencyCallInfo:
   197             {
   299             {
   198             errorCode = RProperty::Set( KPSUidCtsyEmergencyCallInfo, 
   300             errorCode = RProperty::Set( KPSUidCtsyEmergencyCallInfo, 
   199                                         KCTSYEmergencyCallInfo, aValue );
   301                                         KCTSYEmergencyCallInfo, aValue );
   200             TEFLOGSTRING2( KTAERROR, 
   302             TEFLOGSTRING2( KTAERROR,