convergedcallengine/csplugin/src/cspetelcallstatusmonitor.cpp
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     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:  Implementation of class CSPEtelCallStatusMonitor which
       
    15 *                monitors call status changes from ETel and notifies observer
       
    16 *                according to call status change.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <mccpcallobserver.h>
       
    22 
       
    23 #include "cspetelcallstatusmonitor.h"
       
    24 #include "mcspcallobserver.h"
       
    25 #include "csplogger.h"
       
    26 
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CSPEtelCallEventMonitor::NewL.
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CSPEtelCallStatusMonitor* CSPEtelCallStatusMonitor::NewL( MCSPCallObserver& aObserver,
       
    34                                                         RMobileCall& aCall ) 
       
    35     {
       
    36     CSPLOGSTRING(CSPOBJECT, 
       
    37         "CSPEtelCallEventMonitor::NewL()" );
       
    38     CSPEtelCallStatusMonitor* self = new ( ELeave ) CSPEtelCallStatusMonitor( 
       
    39                                         aObserver, aCall );
       
    40     return self;    
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Destructs the object by canceling first ongoing monitoring.
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CSPEtelCallStatusMonitor::~CSPEtelCallStatusMonitor( )
       
    49     {
       
    50     CSPLOGSTRING(CSPOBJECT, 
       
    51         "CSPEtelCallStatusMonitor::~CSPEtelCallStatusMonitor()" );
       
    52     Cancel();
       
    53        
       
    54     if ( iDestrPtr )
       
    55         {
       
    56         *iDestrPtr = ETrue;
       
    57         iDestrPtr = NULL;
       
    58         }
       
    59         
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Starts the monitoring.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CSPEtelCallStatusMonitor::StartMonitoring()
       
    68     {
       
    69     CSPLOGSTRING(CSPINT, "CSPEtelCallStatusMonitor::StartMonitoring()" );
       
    70     if ( !IsActive() && iCall.SubSessionHandle() )
       
    71         {
       
    72         CSPLOGSTRING( CSPREQOUT, 
       
    73             "CSP: CSPEtelCallStatusMonitor::StartMonitoring: Request \
       
    74                     RMobilePhone::NotifyMobileCallStatusChange" );
       
    75         iCall.NotifyMobileCallStatusChange( iStatus, iCallStatus );
       
    76         CSPLOGSTRING( CSPREQOUT, "CSPEtelCallStatusMonitor:: Notify OK" );
       
    77         SetActive();
       
    78         }
       
    79     else
       
    80         {
       
    81         CSPLOGSTRING( CSPERROR, 
       
    82             "CSP: CSPEtelCallStatusMonitor::StartMonitoring: Already active" );
       
    83         }
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Starts the monitoring.
       
    89 // ---------------------------------------------------------------------------
       
    90 //    
       
    91 RMobileCall::TMobileCallStatus CSPEtelCallStatusMonitor::State()
       
    92     {
       
    93     return iCallStatus;
       
    94     }
       
    95     
       
    96 // ---------------------------------------------------------------------------
       
    97 // From CActive
       
    98 // Handles call status notifying.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CSPEtelCallStatusMonitor::RunL()
       
   102     {
       
   103     CSPLOGSTRING( CSPINT, "CSPEtelCallStatusMonitor::RunL")   
       
   104     
       
   105     // Survive from monitor destruction during observing sequence
       
   106     TBool destroyed = EFalse;
       
   107     iDestrPtr = &destroyed;
       
   108      
       
   109     if ( iStatus == KErrNone )
       
   110         {
       
   111         iObserver.NotifyCallStateChangedETel( iCallStatus );
       
   112         }
       
   113     
       
   114     if ( !destroyed )
       
   115         {        
       
   116         // In case instance has not been deleted, pointer must be cleared.
       
   117         iDestrPtr = NULL;
       
   118         if ( iStatus == KErrNone )
       
   119             {
       
   120             StartMonitoring();
       
   121             }
       
   122         }
       
   123     else
       
   124         {
       
   125         // already destroyed, do not touch members.
       
   126         }
       
   127     }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // From CActive
       
   132 // Canceling functionality.
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CSPEtelCallStatusMonitor::DoCancel()
       
   136     {
       
   137     CSPLOGSTRING( CSPINT, "CSPEtelCallStatusMonitor::DoCancel" );
       
   138     iCall.CancelAsyncRequest( EMobileCallNotifyMobileCallStatusChange );
       
   139     }
       
   140 
       
   141 
       
   142 
       
   143     
       
   144 // ---------------------------------------------------------------------------
       
   145 // Constructs the monitor..
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 CSPEtelCallStatusMonitor::CSPEtelCallStatusMonitor( MCSPCallObserver& aObserver,
       
   149                                                     RMobileCall& aCall ) : 
       
   150                                    CActive( EPriorityStandard ),
       
   151                                    iObserver( aObserver ),
       
   152                                    iCall ( aCall )
       
   153     {
       
   154     CSPLOGSTRING(CSPOBJECT, 
       
   155         "CSPEtelCallStatusMonitor::CSPEtelCallStatusMonitor()" );
       
   156     CActiveScheduler::Add( this );
       
   157     }
       
   158     
       
   159 
       
   160 
       
   161 // End of file