convergedconnectionhandler/cchclientapi/cchuinotif/src/cchuicallstatelistener.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2009 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: CCH UI Call State Listener
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ctsydomainpskeys.h>
       
    20 
       
    21 #include  "cchuicallstatelistener.h"
       
    22 #include  "cchuicallstateobserver.h"
       
    23 #include  "cchuilogger.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CCchUiCallStateListener::CCchUiCallStateListener
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CCchUiCallStateListener::CCchUiCallStateListener(
       
    33     MCchUiCallStateObserver& aObserver ):
       
    34     CActive( CActive::EPriorityStandard ),
       
    35     iObserver( aObserver )
       
    36     {
       
    37     CActiveScheduler::Add( this );
       
    38     
       
    39     iProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState );
       
    40     IssueRequest();
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CCchUiCallStateListener::NewL
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CCchUiCallStateListener* CCchUiCallStateListener::NewL(
       
    48     MCchUiCallStateObserver& aObserver )
       
    49     {
       
    50     CCchUiCallStateListener* self = new ( ELeave ) CCchUiCallStateListener(
       
    51         aObserver );
       
    52     CCHUIDEBUG2( "CCchUiCallStateListener::NewL this=%d", (TInt)self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CCchUiCallStateListener::~CCchUiCallStateListener
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CCchUiCallStateListener::~CCchUiCallStateListener()
       
    61     {
       
    62     CCHUIDEBUG( "CCchUiCallStateListener::~CCchUiCallStateListener - Start" );
       
    63     
       
    64     Cancel();
       
    65     iProperty.Close();
       
    66     
       
    67     CCHUIDEBUG( "CCchUiCallStateListener::~CCchUiCallStateListener - End" );
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // From class CActive
       
    72 // CCchUiCallStateListener::RunL
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CCchUiCallStateListener::RunL()
       
    76     { 
       
    77     if ( iStatus.Int() == KErrNone )
       
    78         {
       
    79         HandleChange();
       
    80         }
       
    81     IssueRequest();
       
    82     }
       
    83 
       
    84 // ----------------------------------------------------------
       
    85 // From class CActive
       
    86 // CCchUiCallStateListener::DoCancel
       
    87 // ----------------------------------------------------------
       
    88 //
       
    89 void CCchUiCallStateListener::DoCancel()
       
    90     {
       
    91     iProperty.Cancel();
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CCchUiCallStateListener::HandleChange
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CCchUiCallStateListener::HandleChange()
       
    99     {
       
   100     CCHUIDEBUG( "CCchUiCallStateListener::HandleChange - Start" );
       
   101     
       
   102     TInt err = RProperty::Get( KPSUidCtsyCallInformation,
       
   103                                KCTsyCallState,
       
   104                                iCallState );
       
   105     if ( err == KErrNone )
       
   106         {
       
   107         iObserver.CallStateChanged( iCallState );
       
   108         }
       
   109     
       
   110     CCHUIDEBUG( "CCchUiCallStateListener::HandleChange - End" );
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CCchUiCallStateListener::IssueRequest
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CCchUiCallStateListener::IssueRequest()
       
   118     {
       
   119     if ( !IsActive() )
       
   120         {
       
   121         iProperty.Subscribe( iStatus );
       
   122         SetActive();
       
   123         }
       
   124     }