phoneengine/phonemodel/src/cpeaudiooutputpreferencemonitor.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:  This module contains the implementation of CPEAudioOutputPreferenceMonitor class 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "cpeaudiooutputpreferencemonitor.h"
       
    21 #include "cpepubsubmonitor.h"
       
    22 #include "mpephonemodelinternal.h"
       
    23 #include <e32property.h>
       
    24 #include <mpedatastore.h>
       
    25 #include <talogger.h>
       
    26 #include <telinternalpskeys.h>
       
    27 
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CPEAudioOutputPreferenceMonitor::NewL
       
    33 // Two-phased constructor.
       
    34 // -----------------------------------------------------------------------------
       
    35 CPEAudioOutputPreferenceMonitor* CPEAudioOutputPreferenceMonitor::NewL(
       
    36         MPEPhoneModelInternal& aModel ) 
       
    37     {
       
    38     TEFLOGSTRING( KTAOBJECT, "PE CPEAudioOutputPreferenceMonitor::NewL");
       
    39     CPEAudioOutputPreferenceMonitor* self = new (ELeave) CPEAudioOutputPreferenceMonitor( aModel );
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     return( self );
       
    44     }
       
    45                                                                             
       
    46 // -----------------------------------------------------------------------------
       
    47 // CPEAudioOutputPreferenceMonitor::CPEAudioOutputPreferenceMonitor
       
    48 // C++ default constructor can NOT contain any code, that
       
    49 // might leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CPEAudioOutputPreferenceMonitor::CPEAudioOutputPreferenceMonitor(
       
    53         MPEPhoneModelInternal& aModel
       
    54         ): CPEPubSubMonitor( aModel )
       
    55     {
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CPEAudioOutputPreferenceMonitor::ConstructL
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CPEAudioOutputPreferenceMonitor::ConstructL()
       
    64     {
       
    65     TEFLOGSTRING( KTAOBJECT, "PE CPEAudioOutputPreferenceMonitor::ConstructL");
       
    66    
       
    67     BaseConstructL( KPSUidTelAudioPreference, KTelAudioOutput, RProperty::EInt );
       
    68   
       
    69     //  Now retrieve the value
       
    70     TInt value;
       
    71     TInt error = Get( value );
       
    72     
       
    73     // if not able to retrieve the value, set it to the default value
       
    74     if ( error != KErrNone )
       
    75         {   
       
    76         value = EPSAudioPrivate;
       
    77         }
       
    78    
       
    79     iModel.DataStore()->SetAudioOutputPreference( static_cast<EPSTelAudioOutput>(value) );
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CPECenRepMonitor::UpdateL
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CPEAudioOutputPreferenceMonitor::UpdateL()
       
    87     {
       
    88     TEFLOGSTRING( KTAINT, "PE CPEAudioOutputPreferenceMonitor::UpdateL" );
       
    89    
       
    90     //  Now retrieve the value
       
    91     TInt value;
       
    92     User::LeaveIfError(Get(value)); 
       
    93     
       
    94     TInt old = iModel.DataStore()->AudioOutputPreference();
       
    95     
       
    96     // If value has not changed, do not send message about change.
       
    97     // This reason for this check is that during phone startup sequence,
       
    98     // the key gets updated but phoneengine already has te value correctly.
       
    99     if (value != old)
       
   100         {
       
   101         iModel.DataStore()->SetAudioOutputPreference( static_cast<EPSTelAudioOutput>(value) );    
       
   102         iModel.SendMessage( MEngineMonitor::EPEMessageAudioOutputPreferenceChanged );
       
   103         }
       
   104     }
       
   105     
       
   106 // End of file