coreapplicationuis/SysAp/Src/sysapaudioroutingobserver.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Observes changes in audio output routing.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "sysapaudioroutingobserver.h"
       
    20 #include "SysAp.hrh"
       
    21 #include "SysApAppUi.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CSysApAudioRoutingObserver
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CSysApAudioRoutingObserver::CSysApAudioRoutingObserver( CSysApAppUi& aSysApAppUi ) :  
       
    28                                                             iTelephonyAudioRouting( NULL ),
       
    29                                                             iSysApAppUi( aSysApAppUi )
       
    30     {
       
    31     }
       
    32 
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // ConstructL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CSysApAudioRoutingObserver::ConstructL()
       
    39     {
       
    40     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::ConstructL") ) );
       
    41     iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this );
       
    42     }
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // NewL
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CSysApAudioRoutingObserver* CSysApAudioRoutingObserver::NewL( CSysApAppUi& aSysApAppUi )
       
    50     {
       
    51     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::NewL") ) );
       
    52     CSysApAudioRoutingObserver* self = new( ELeave ) CSysApAudioRoutingObserver( aSysApAppUi );
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL();
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // ~CSysApAudioRoutingObserver
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CSysApAudioRoutingObserver::~CSysApAudioRoutingObserver()
       
    64     {
       
    65     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::~CSysApAudioRoutingObserver") ) );
       
    66     delete iTelephonyAudioRouting;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // IhfEnabled
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 TBool CSysApAudioRoutingObserver::IhfEnabled() const
       
    74     {
       
    75     CTelephonyAudioRouting::TAudioOutput audioOutput = iTelephonyAudioRouting->Output();
       
    76     
       
    77     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::IhfEnabled: audioOutput=%d"), audioOutput ) );
       
    78     
       
    79     return ( audioOutput == CTelephonyAudioRouting::ELoudspeaker );
       
    80     
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // From class MTelephonyAudioRoutingObserver.
       
    85 // AvailableOutputsChanged
       
    86 // ---------------------------------------------------------------------------
       
    87 //    
       
    88 void CSysApAudioRoutingObserver::AvailableOutputsChanged( CTelephonyAudioRouting& /*aTelephonyAudioRouting*/ )
       
    89     {
       
    90     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::AvailableOutputsChanged") ) );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // From class MTelephonyAudioRoutingObserver.
       
    95 // OutputChanged
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CSysApAudioRoutingObserver::OutputChanged( CTelephonyAudioRouting& /*aTelephonyAudioRouting*/ )
       
    99     {
       
   100     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::OutputChanged") ) );
       
   101     TRAPD( err, 
       
   102            iSysApAppUi.SetIhfIndicatorL();
       
   103            iSysApAppUi.SetHacIndicatorL();
       
   104          );
       
   105     
       
   106     if ( err != KErrNone )
       
   107         {
       
   108         TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::OutputChanged: err=%d"), err ) );
       
   109         }
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // From class MTelephonyAudioRoutingObserver.
       
   114 // SetOutputComplete
       
   115 // ---------------------------------------------------------------------------
       
   116 //  
       
   117 void CSysApAudioRoutingObserver::SetOutputComplete( CTelephonyAudioRouting& /*aTelephonyAudioRouting*/, TInt /*aError*/ )
       
   118     {
       
   119     TRACES( RDebug::Print( _L("CSysApAudioRoutingObserver::SetOutputComplete") ) );
       
   120     }