phoneplugins/csplugin/src/cspcallinfomonitor.cpp
changeset 37 ba76fc04e6c2
parent 21 92ab7f8d0eab
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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:  Monitors changes in remote party info.
       
    15 *  Interface   : 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 //  INCLUDE FILES
       
    22 
       
    23 #include    "cspcallinfomonitor.h"       
       
    24 #include    "mcspcallobserver.h"
       
    25 #include    "csppanic.pan"
       
    26 #include    "csplogger.h" //Debug
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS =============================
       
    30 
       
    31 //----------------------------------------------------------------------------
       
    32 //  CSPCallInfoMonitor::NewL()
       
    33 //
       
    34 //  1st phase constructor
       
    35 //----------------------------------------------------------------------------
       
    36 //
       
    37 CSPCallInfoMonitor* CSPCallInfoMonitor::NewL
       
    38     ( MCSPCallObserver& aObserver,
       
    39       RMobileCall& aCall  )   
       
    40     {
       
    41     CSPCallInfoMonitor* self = new (ELeave) CSPCallInfoMonitor( aObserver,
       
    42                                                                 aCall ); 
       
    43     return self;
       
    44     }
       
    45 
       
    46 //----------------------------------------------------------------------------
       
    47 //  CSPCallInfoMonitor::~CSPCallInfoMonitor()
       
    48 //
       
    49 //  d'tor.
       
    50 //----------------------------------------------------------------------------
       
    51 //
       
    52 CSPCallInfoMonitor::~CSPCallInfoMonitor()
       
    53     {    
       
    54     Cancel();
       
    55     CSPLOGSTRING( CSPINT, "CSP: CSPCallInfoMonitor::~CSPCallInfoMonitor" );
       
    56     }
       
    57 
       
    58 //----------------------------------------------------------------------------
       
    59 //  CSPCallInfoMonitor::StartMonitor()
       
    60 //
       
    61 //  Starts monitoring.
       
    62 //----------------------------------------------------------------------------
       
    63 //
       
    64 void CSPCallInfoMonitor::StartMonitoring()
       
    65     {    
       
    66     // error ignored (starting notification doesn't leave)
       
    67     if (!IsActive()) 
       
    68         {
       
    69         iCall.NotifyRemotePartyInfoChange( 
       
    70             iStatus,  
       
    71             iRemotePartyInfoPckg ); 
       
    72         SetActive();             
       
    73         }
       
    74     else
       
    75         {
       
    76         CSPLOGSTRING( CSPERROR, 
       
    77             "CSP: CSPCallInfoMonitor::StartMonitoring: Already active" );
       
    78         
       
    79         }
       
    80     }
       
    81 
       
    82 //----------------------------------------------------------------------------
       
    83 //  CSPCallInfoMonitor::RunL()
       
    84 //
       
    85 //  Handling of the status changes.
       
    86 //----------------------------------------------------------------------------
       
    87 //
       
    88 void CSPCallInfoMonitor::RunL()
       
    89     {
       
    90     CSPLOGSTRING2( CSPINT, 
       
    91         "CSP: CSPCallInfoMonitor::RunL iStatus: %d", iStatus.Int() );
       
    92 
       
    93     RMobileCall::TMobileCallRemoteIdentityStatus idStatus = 
       
    94         iRemotePartyInfo.iRemoteIdStatus;
       
    95     CSPLOGSTRING2( CSPINT, 
       
    96         "CSP: CSPCallInfoMonitor::RunL id status: %d", idStatus );
       
    97 
       
    98     switch ( iStatus.Int() )
       
    99         {
       
   100         case KErrNone:
       
   101             {                
       
   102             if ( idStatus == RMobileCall::ERemoteIdentityAvailable) 
       
   103                 {
       
   104                 iObserver.NotifyRemotePartyInfoChanged(
       
   105                     iRemotePartyInfo.iCallingName);
       
   106                 }
       
   107             else
       
   108                 {
       
   109                 CSPLOGSTRING2( CSPERROR, 
       
   110                 "CSP: CSPCallInfoMonitor::RunL DISCARD: %d", idStatus );
       
   111                 }            
       
   112             break;
       
   113             }
       
   114         default:
       
   115             CSPLOGSTRING( CSPERROR, 
       
   116                 "CSP: CSPCallInfoMonitor::RunL error" );
       
   117             break;
       
   118         }
       
   119         
       
   120     if ( KErrNotSupported != iStatus.Int() )
       
   121         {        
       
   122         StartMonitoring();
       
   123         }
       
   124     }
       
   125 
       
   126 //----------------------------------------------------------------------------
       
   127 //  CSPCallInfoMonitor::DoCancel()
       
   128 //
       
   129 //  Implementation of cancel.
       
   130 //----------------------------------------------------------------------------
       
   131 //
       
   132 void CSPCallInfoMonitor::DoCancel()
       
   133     {
       
   134     CSPLOGSTRING( CSPINT, "CSP: CSPCallInfoMonitor::DoCancel" );
       
   135     
       
   136     iCall.CancelAsyncRequest( EMobileCallNotifyRemotePartyInfoChange );
       
   137     }
       
   138 
       
   139 //----------------------------------------------------------------------------
       
   140 //  CSPCallInfoMonitor::CSPCallInfoMonitor()
       
   141 //
       
   142 //  constructor.
       
   143 //----------------------------------------------------------------------------
       
   144 //
       
   145 CSPCallInfoMonitor::CSPCallInfoMonitor( MCSPCallObserver &aObserver, 
       
   146                                         RMobileCall& aCall ) : 
       
   147         CActive( EPriorityStandard ),
       
   148         iObserver( aObserver ),
       
   149         iCall( aCall ),
       
   150         iRemotePartyInfoPckg( iRemotePartyInfo )
       
   151     {
       
   152     CActiveScheduler::Add( this );
       
   153     }
       
   154 
       
   155 // End of file