phoneengine/phonemodel/src/cpeincallloudspeakervolumesettingmonitor.cpp
changeset 0 5f000ab63145
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:  Contains phone engine base central repository monitor class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cpeincallloudspeakervolumesettingmonitor.h"
       
    21 #include "mpephonemodelinternal.h"
       
    22 #include <centralrepository.h>
       
    23 #include <mpedatastore.h>
       
    24 #include <talogger.h>
       
    25 #include <telephonyvariant.hrh>
       
    26 #include <telincallvolcntrlcrkeys.h>
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CPEIncallLoudspeakerVolumeSettingMonitor::NewL
       
    31 // Two-phased constructor.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CPEIncallLoudspeakerVolumeSettingMonitor* CPEIncallLoudspeakerVolumeSettingMonitor::NewL(
       
    35         MPEPhoneModelInternal& aModel
       
    36         )
       
    37     {
       
    38     CPEIncallLoudspeakerVolumeSettingMonitor* me = 
       
    39         new ( ELeave ) CPEIncallLoudspeakerVolumeSettingMonitor( aModel );
       
    40     CleanupStack::PushL( me );
       
    41     me->ConstructL(); 
       
    42     CleanupStack::Pop( me );
       
    43     return ( me );
       
    44     }
       
    45 
       
    46 // Destructor
       
    47 CPEIncallLoudspeakerVolumeSettingMonitor::~CPEIncallLoudspeakerVolumeSettingMonitor()
       
    48     {
       
    49     // Cancel() is called by base class destructor, which also deletes iRepository
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CPEIncallLoudspeakerVolumeSettingMonitor::CPEIncallLoudspeakerVolumeSettingMonitor
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CPEIncallLoudspeakerVolumeSettingMonitor::CPEIncallLoudspeakerVolumeSettingMonitor(
       
    59         MPEPhoneModelInternal& aModel
       
    60         ) : CPECenRepMonitor( KTelIncallLoudspeakerVolume ),
       
    61             iModel( aModel ),
       
    62             iUpdateInProgress( EFalse )
       
    63     {
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CPEIncallLoudspeakerVolumeSettingMonitor::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CPEIncallLoudspeakerVolumeSettingMonitor::ConstructL()
       
    72     {
       
    73     BaseConstructL( KCRUidInCallVolume );
       
    74 
       
    75     TInt volume = KPEDefaultAudioVolume; // Default setting
       
    76     Get( volume );   
       
    77     TEFLOGSTRING2( 
       
    78         KTAREQOUT, 
       
    79         "PE CPEIncallLoudspeakerVolumeSettingMonitor::ConstructL, Incall loudspeaker volume = %d ",
       
    80         volume );
       
    81     //In boot, cannot write volume value to datastore. It override HeadSet mode 
       
    82     // volume ( default value ).
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CPEIncallLoudspeakerVolumeSettingMonitor::Set
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 TInt CPEIncallLoudspeakerVolumeSettingMonitor::Set(
       
    90         TInt aValue
       
    91         )
       
    92     {
       
    93     TInt errorCode( KErrNone );
       
    94 
       
    95     // Check whether this function call was initiated by a central repository
       
    96     // change notification.
       
    97     if( iUpdateInProgress == EFalse )
       
    98         {
       
    99         errorCode = iRepository->Set( iMonitorSetting, aValue );
       
   100         TEFLOGSTRING3( KTAREQOUT, "PE CPEIncallLoudspeakerVolumeSettingMonitor::Set \
       
   101 > CRepository::Set, Incall loudspeaker volume = %d, error code: %d", aValue, errorCode );
       
   102         }
       
   103 
       
   104     return errorCode;
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPEIncallLoudspeakerVolumeSettingMonitor::UpdateL
       
   109 // Symbian 2nd phase constructor can leave.
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CPEIncallLoudspeakerVolumeSettingMonitor::UpdateL()
       
   113     {
       
   114     TInt volume;
       
   115     // The loudspeaker volume has changed in repository.
       
   116     // Retrieve the current volume from repository.
       
   117     User::LeaveIfError( Get( volume ) );
       
   118 
       
   119     TEFLOGSTRING2( 
       
   120         KTAREQOUT,
       
   121         "PE CPEIncallLoudspeakerVolumeSettingMonitor::UpdateL, Incall loudspeaker volume = %d ",
       
   122         volume );
       
   123 
       
   124     // Update loudspeaker volume using an audiohandling routine
       
   125     // The routine will try to update the repository as well,
       
   126     // ensure this is blocked using an internal flag.
       
   127     iUpdateInProgress = ETrue;
       
   128     iModel.DataStore()->SetAudioVolumeCommand( volume );
       
   129     iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageSetAudioVolume );
       
   130 
       
   131     // Reset the flag when synchronization is complete
       
   132     iUpdateInProgress = EFalse;
       
   133     }
       
   134 
       
   135 // End of file