javauis/mmapi_akn/baseline/src/cmmacallstatemonitor.cpp
branchRCL_3
changeset 24 6c158198356e
equal deleted inserted replaced
23:e5618cc85d74 24:6c158198356e
       
     1 /*
       
     2 * Copyright (c) 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:  Publish and Subscribe key watcher
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include "cmmacallstatemonitor.h"
       
    21 #include "mmmacallstateobserver.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Default Constructor
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CMMACallStateMonitor::CMMACallStateMonitor(  TUid aUid, TInt aKey,
       
    28                                      MMMACallStateObserver* aObserver ) :
       
    29                                                      CActive( EPriorityHigh ),
       
    30                                                      iObserver( aObserver ),
       
    31                                                      iUid( aUid ),
       
    32                                                      iKey( aKey )
       
    33                                                       
       
    34     {
       
    35     }
       
    36 
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // 2nd phased Constructor
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 void CMMACallStateMonitor::ConstructL()
       
    43     {
       
    44     CActiveScheduler::Add(this);
       
    45     
       
    46     iProperty.Attach( iUid, iKey );
       
    47     iProperty.Subscribe( iStatus );
       
    48     SetActive();
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Two-Phased COnstructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CMMACallStateMonitor* CMMACallStateMonitor::NewL( TUid aUid, TInt aKey,
       
    57                                                    MMMACallStateObserver* aObserver )
       
    58     {
       
    59     CMMACallStateMonitor* self = new(ELeave) CMMACallStateMonitor( aUid, 
       
    60                                                            aKey, 
       
    61                                                            aObserver );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Destructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CMMACallStateMonitor::~CMMACallStateMonitor()
       
    74     {
       
    75     Cancel();  // Cancels waiting request
       
    76     iProperty.Close();
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CMMAPSKeyWatcher::RunL
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CMMACallStateMonitor::RunL()
       
    84     {
       
    85     iProperty.Subscribe( iStatus );
       
    86     SetActive();
       
    87     
       
    88     // Notify Observer and start watching again
       
    89     if( iObserver )
       
    90         {
       
    91         iObserver->HandleCallStateEventL( iUid, iKey );
       
    92         }
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CMMAPSKeyWatcher::DoCancel
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CMMACallStateMonitor::DoCancel()
       
   100     {
       
   101     iProperty.Cancel();
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CMMAPSKeyWatcher::GetValue
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 TInt CMMACallStateMonitor::GetValue( TInt& aValue )
       
   109     {
       
   110     return iProperty.Get( aValue );
       
   111     }
       
   112