idlefw/src/framework/aicallstatusobserver.cpp
branchRCL_3
changeset 8 d0529222e3f0
parent 4 1a2a00e78665
child 11 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 8:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-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:  Call status observer for AI2
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aipspropertyobserver.h>
       
    20 #include <ctsydomainpskeys.h>
       
    21 #include "aicallstatusobserver.h"
       
    22 #include "aistatemanager.h"
       
    23 #include "aifwpanic.h"
       
    24 #include "debug.h"
       
    25 
       
    26 CAiCallStatusObserver::CAiCallStatusObserver()
       
    27     {
       
    28     }
       
    29     
       
    30 CAiCallStatusObserver::~CAiCallStatusObserver()
       
    31     {
       
    32     }
       
    33 
       
    34 CAiCallStatusObserver* CAiCallStatusObserver::NewL( MAiStateManager* aStateManager )
       
    35     {
       
    36     CAiCallStatusObserver* self = new (ELeave) CAiCallStatusObserver();
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL( aStateManager );
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41     }
       
    42 
       
    43 void CAiCallStatusObserver::ConstructL( MAiStateManager* aStateManager )
       
    44     {
       
    45     BaseConstructL( TCallBack( HandleCallStateChange, this ),
       
    46                     KPSUidCtsyCallInformation,
       
    47                     KCTsyCallState,
       
    48                     aStateManager );
       
    49     }
       
    50     
       
    51 TAiStateChanges CAiCallStatusObserver::Status()
       
    52     {
       
    53     TInt value = 0;
       
    54     TInt err = iObserver->Get( value );
       
    55     if( ( value > EPSCTsyCallStateNone ) &&
       
    56         ( err == KErrNone ) )
       
    57         {
       
    58         return ESMAIInCall;
       
    59         }
       
    60     else
       
    61         {
       
    62         return ESMAINoCall;
       
    63         } 
       
    64     }
       
    65 
       
    66 TInt CAiCallStatusObserver::HandleCallStateChange( TAny* aPtr )
       
    67     {
       
    68     CAiCallStatusObserver* self = reinterpret_cast< CAiCallStatusObserver* >( aPtr );
       
    69 
       
    70     __ASSERT_DEBUG( self, 
       
    71                     AiFwPanic::Panic( AiFwPanic::EAiFwPanic_NullPointerReference ) );
       
    72 
       
    73     TInt value = 0;
       
    74     TInt err = self->iObserver->Get( value );
       
    75                  
       
    76     if( ( value > EPSCTsyCallStateNone ) &&
       
    77         ( err == KErrNone ) )
       
    78         {
       
    79         __PRINTS("XAI: Call = ON");
       
    80         self->iStateManager->ReportStateChange( ESMAIInCall );
       
    81         }
       
    82     else
       
    83         {
       
    84         __PRINTS("XAI: Call = OFF");
       
    85         self->iStateManager->ReportStateChange( ESMAINoCall );
       
    86         } 
       
    87     return KErrNone;
       
    88     }
       
    89