phoneengine/phonemodel/src/cpeexternaldatahandler.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This module contains the implementation of 
       
    15 *                CPEExternalDataHandler class 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cpeexternaldatahandler.h"
       
    22 #include "mpephonemodelinternal.h"
       
    23 #include <accessoriescrkeys.h>
       
    24 #include <centralrepository.h>
       
    25 #include <CoreApplicationUIsSDKCRKeys.h>
       
    26 #include <ctsydomainpskeys.h>
       
    27 #include <mpedatastore.h>
       
    28 #include <pepanic.pan>
       
    29 #include <SettingsInternalCRKeys.h>
       
    30 #include <talogger.h>
       
    31 #include <telephonyvariant.hrh>
       
    32 #include <telinternalcrkeys.h>
       
    33 
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KPrefixLength = 10;
       
    37 
       
    38 CPEExternalDataHandler* CPEExternalDataHandler::NewL( MPEPhoneModelInternal& aModel )
       
    39     {
       
    40     CPEExternalDataHandler* self = new ( ELeave ) CPEExternalDataHandler( *aModel.DataStore() );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL( aModel );
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CPEExternalDataHandler::CPEExternalDataHandler
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CPEExternalDataHandler::CPEExternalDataHandler(
       
    54         MPEDataStore& aDataStore
       
    55         ) : iDataStore( aDataStore )
       
    56     {
       
    57     }
       
    58 
       
    59 // Destructor
       
    60 CPEExternalDataHandler::~CPEExternalDataHandler()
       
    61     {
       
    62     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::~CPEExternalDataHandler" );    
       
    63 
       
    64     delete iTelephonyVariationRepository;
       
    65     delete iTelephonySettingsRepository;
       
    66     delete iProfileSettings;
       
    67     delete iNetworkRegistrationStatus;
       
    68     delete iLoudspeakerVolumeSetting;
       
    69     delete iEarVolumeSetting;
       
    70     delete iCallDurationDisplay;
       
    71     delete iAudioOutputPreferenceMonitor;
       
    72     delete iAccessorySettingsRepository;
       
    73     delete iAccessoryModeMonitor;
       
    74     delete iCoreApplicationRepository;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CPEExternalDataHandler::BaseConstructL
       
    79 // Symbian 2nd phase constructor can leave.
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CPEExternalDataHandler::ConstructL(
       
    83         MPEPhoneModelInternal& aModel )
       
    84     {
       
    85     TEFLOGSTRING( KTAOBJECT, "PE CPEExternalDataHandler::BaseConstructL" );
       
    86 
       
    87     // Instantiate monitor objects
       
    88     iAudioOutputPreferenceMonitor = CPEAudioOutputPreferenceMonitor::NewL( aModel );
       
    89     iCallDurationDisplay = CPECallDurationDisplaySettingMonitor::NewL();
       
    90     iEarVolumeSetting = CPEIncallEarVolumeSettingMonitor::NewL( aModel );
       
    91     iLoudspeakerVolumeSetting = CPEIncallLoudspeakerVolumeSettingMonitor::NewL( aModel );
       
    92     iNetworkRegistrationStatus = CPENetworkRegistrationStatusMonitor::NewL( aModel );
       
    93     iProfileSettings = CPEProfileSettingMonitor::NewL( aModel );
       
    94     iAccessoryModeMonitor = CPEAccessoryModeMonitor::NewL(); 
       
    95 
       
    96     // Instantiate repository objects for later use
       
    97     iAccessorySettingsRepository = CRepository::NewL( KCRUidAccessorySettings );
       
    98     iTelephonySettingsRepository = CRepository::NewL( KCRUidTelephonySettings );
       
    99     iTelephonyVariationRepository = CRepository::NewL( KCRUidTelVariation );
       
   100     iCoreApplicationRepository = CRepository::NewL( KCRUidCoreApplicationUIs ); 
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPEExternalDataHandler::Get
       
   105 // Gets the current value of the specified setting, if the operation was successful
       
   106 // aValue contains the current valid value of the setting
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 TInt CPEExternalDataHandler::Get(
       
   110         const TPEExternalDataId aSetting,
       
   111         TInt& aValue ) const
       
   112     {
       
   113     TInt errorCode( KErrNotFound );
       
   114 
       
   115     // Process Common id
       
   116     switch ( aSetting )
       
   117         {
       
   118         case EPEAutomaticAnswerHeadsetSetting:
       
   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             }
       
   213         }
       
   214 
       
   215     return errorCode;
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CPEExternalDataHandler::Get
       
   220 // Gets the current value of the specified setting, if the operation was successful
       
   221 // aValue contains the current valid value of the setting
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TInt CPEExternalDataHandler::GetText(
       
   225         const TPEExternalDataId aSetting,
       
   226         TDesC& aValue ) const
       
   227     {
       
   228     TInt errorCode( KErrNotFound );
       
   229 
       
   230     // Process Common id
       
   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 
       
   254     return errorCode;
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CPEExternalDataHandler::GetAutomaticAnswer
       
   259 // Check if automatic answer is defined for connected accessory.
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 TInt CPEExternalDataHandler::GetAutomaticAnswer(
       
   263         TUint32 aSetting,
       
   264         TInt& aValue ) const
       
   265     {
       
   266     TInt errorCode( KErrNotFound );
       
   267     
       
   268     TEFLOGSTRING( KTAINT, "CPEExternalDataHandler::GetAutomaticAnswer" );
       
   269    
       
   270     errorCode = iAccessorySettingsRepository->Get( aSetting, aValue );
       
   271      
       
   272     return errorCode;
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CPEExternalDataHandler::Set
       
   277 // Sets the value of the specified setting
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 TInt CPEExternalDataHandler::Set(
       
   281         const TPEExternalDataId aSetting,
       
   282         const TInt aValue )
       
   283     {
       
   284     TInt errorCode( KErrNotFound );
       
   285 
       
   286     switch ( aSetting )
       
   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             }
       
   298         case EPEEmergencyCallInfo:
       
   299             {
       
   300             errorCode = RProperty::Set( KPSUidCtsyEmergencyCallInfo, 
       
   301                                         KCTSYEmergencyCallInfo, aValue );
       
   302             TEFLOGSTRING2( KTAERROR, 
       
   303             "PE CPEExternalDataHandler::Set KPSUidCtsyEmergencyCallInfo: %d", aValue );
       
   304             break;            
       
   305             }
       
   306         default:
       
   307             {
       
   308             TEFLOGSTRING2( KTAERROR, "PE CPEEXTERNALDATAHANDLER::SET UNKNOWN SETTING ID ! %d", aSetting );
       
   309             break;
       
   310             }
       
   311         }
       
   312     return errorCode;
       
   313     }
       
   314 
       
   315 // End of file