phonecmdhandler/phonecmdhnlr/src/PhoneHandlerCallState.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Listens to call state changes and informs control. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "phonehandlercallstate.h" 
       
    21 #include "phonehandlercontrol.h" 
       
    22 #include "phonehandlerdebug.h" 
       
    23 #include <ctsydomainpskeys.h>
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CPhoneHandlerCallState::CPhoneHandlerCallState
       
    48 // C++ default constructor can NOT contain any code, that
       
    49 // might leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CPhoneHandlerCallState::CPhoneHandlerCallState( CPhoneHandlerControl& aControl )
       
    53 :   CActive(CActive::EPriorityStandard),
       
    54     iControl( aControl )
       
    55     {
       
    56     CActiveScheduler::Add(this);
       
    57     } 
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPhoneHandlerCallState::ConstructL
       
    61 // Symbian 2nd phase constructor can leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CPhoneHandlerCallState::ConstructL()
       
    65     {
       
    66     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() start" );
       
    67     
       
    68     // Allows CPhoneHandlerCallState to start to listen S60 call states.
       
    69     User::LeaveIfError( 
       
    70         iProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
    71         
       
    72     Subscribe();
       
    73     
       
    74     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() end" );
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CPhoneHandlerCallState::NewL
       
    79 // Two-phased constructor.
       
    80 // -----------------------------------------------------------------------------
       
    81 CPhoneHandlerCallState* CPhoneHandlerCallState::NewL( CPhoneHandlerControl& aControl )
       
    82     {
       
    83     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::NewL()" );
       
    84     
       
    85     CPhoneHandlerCallState* self = new(ELeave) CPhoneHandlerCallState( aControl );
       
    86     CleanupStack::PushL( self );
       
    87     self->ConstructL();
       
    88     CleanupStack::Pop( self );
       
    89     
       
    90     return self;
       
    91     }
       
    92 
       
    93 // Destructor
       
    94 CPhoneHandlerCallState::~CPhoneHandlerCallState()
       
    95     {
       
    96     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() start" );
       
    97     
       
    98     Cancel();
       
    99     iProperty.Cancel();
       
   100     iProperty.Close();
       
   101     
       
   102     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() end" );
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CPhoneHandlerCallState::RunL()
       
   107 // Informs caller of an asynchronous request that it has been completed.
       
   108 // (other items were commented in a header).
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CPhoneHandlerCallState::RunL()
       
   112     {
       
   113     COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerCallState::RunL() - return code = %d", iStatus.Int() );
       
   114         
       
   115     TInt state( 0 );
       
   116     iProperty.Get( state );
       
   117     
       
   118     COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerCallState - KTelephonyCallState = %d", state );
       
   119         
       
   120     if( iStatus.Int() == KErrNone )
       
   121         {
       
   122         iControl.NotifyCallState( state );
       
   123         }
       
   124         
       
   125     Subscribe();
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CPhoneHandlerCallState::DoCancel
       
   130 // (other items were commented in a header).
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CPhoneHandlerCallState::DoCancel()
       
   134     {
       
   135     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::DoCancel()" );
       
   136     
       
   137     iProperty.Cancel();
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CPhoneHandlerCallState::Subscribe
       
   142 // Start to listen changes in call state.
       
   143 // (other items were commented in a header).
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CPhoneHandlerCallState::Subscribe()
       
   147     {
       
   148     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::Subscribe()" );
       
   149     
       
   150     iProperty.Subscribe( iStatus );
       
   151     SetActive();
       
   152     }
       
   153 
       
   154 //
       
   155 // End of file