convergedcallengine/csplugin/src/cspeteldtmfstopmonitor.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:  Implements the class CSPEtelDtmfStopMonitor
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <mccpdtmfobserver.h>
       
    21 #include <gsmerror.h>
       
    22 
       
    23 #include "cspeteldtmfstopmonitor.h"
       
    24 #include "csplogger.h"
       
    25 #include "cspdtmfprovider.h"
       
    26 #include "cspconsts.h"
       
    27 #include "cspdtmfprovider.h"
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CSPEtelDtmfStopMonitor::NewL.
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CSPEtelDtmfStopMonitor* CSPEtelDtmfStopMonitor::NewL( 
       
    35                                         CSPDTMFProvider& aObserver, 
       
    36                                         RMobilePhone& aPhone ) 
       
    37     {
       
    38     CSPLOGSTRING(CSPOBJECT, 
       
    39         "CSPEtelDtmfStopMonitor::NewL()" );
       
    40     CSPEtelDtmfStopMonitor* self = new ( ELeave ) CSPEtelDtmfStopMonitor( 
       
    41                                         aObserver, aPhone );
       
    42     return self;    
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructs the object by canceling first ongoing monitoring.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CSPEtelDtmfStopMonitor::~CSPEtelDtmfStopMonitor( )
       
    50     {
       
    51     CSPLOGSTRING(CSPOBJECT, 
       
    52         "CSPEtelDtmfStopMonitor::~CSPEtelDtmfStopMonitor()" );
       
    53     Cancel();
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // Starts the monitor.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void CSPEtelDtmfStopMonitor::StartMonitoring()
       
    61     {
       
    62     CSPLOGSTRING(CSPINT, "CSPEtelDtmfStopMonitor::StartMonitoring()" );
       
    63 
       
    64     if ( !IsActive() )
       
    65         {
       
    66         CSPLOGSTRING( CSPINT, 
       
    67             "CSP: CSPEtelDtmfStopMonitor::StartMonitoring: Request \
       
    68                     iPhone.NotifyStopInDTMFString( iStatus, iEventData )" );
       
    69         iPhone.NotifyStopInDTMFString( iStatus );
       
    70         SetActive();
       
    71         }
       
    72     else
       
    73         {
       
    74         CSPLOGSTRING( CSPERROR, 
       
    75             "CSP: CSPEtelDtmfStopMonitor::StartMonitoring: Already active" );
       
    76         }
       
    77     }
       
    78 // ---------------------------------------------------------------------------
       
    79 // From CActive.
       
    80 // Handles line status change notifying.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CSPEtelDtmfStopMonitor::RunL()
       
    84     {
       
    85     TInt err = iStatus.Int();
       
    86     CSPLOGSTRING2( CSPINT, 
       
    87         "CSPEtelDtmfStopMonitor::RunL: status: %d", err );
       
    88     
       
    89     if ( err != KErrCancel &&  err != KErrServerTerminated )
       
    90         {
       
    91         
       
    92         TChar tone = NULL;
       
    93         MCCPDTMFObserver::TCCPDtmfEvent event = 
       
    94                 MCCPDTMFObserver::ECCPDtmfStopInDtmfString;
       
    95         iObserver.NotifyDTMFEvent( event, err, tone );
       
    96         }
       
    97     else
       
    98         {
       
    99         CSPLOGSTRING2( CSPERROR, "CSPEtelDtmfStopMonitor::RunL: Error \
       
   100                     from RMobilePhone: %d", iStatus.Int() );
       
   101         }
       
   102     
       
   103     
       
   104     // Continue if not in offline mode
       
   105     if ( err != KErrGsmOfflineOpNotAllowed && err != KErrCancel
       
   106         && err != KErrNotSupported )
       
   107         {
       
   108         StartMonitoring();
       
   109         }
       
   110     CSPLOGSTRING( CSPREQEND, "CSPEtelDtmfStopMonitor::RunL End of RunL." );
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // From CActive
       
   115 // Canceling functionality.
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CSPEtelDtmfStopMonitor::DoCancel()
       
   119     {
       
   120     if ( iStatus == KRequestPending )
       
   121         {
       
   122         CSPLOGSTRING( CSPINT, 
       
   123             "CSPEtelDtmfStopMonitor::DoCancel Canceling pending request.." );
       
   124         iPhone.CancelAsyncRequest( EMobilePhoneNotifyStopInDTMFString );
       
   125 
       
   126         }
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // Constructs the monitor.
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 CSPEtelDtmfStopMonitor::CSPEtelDtmfStopMonitor(
       
   134             CSPDTMFProvider& aObserver, 
       
   135             RMobilePhone& aPhone ) : 
       
   136             CActive( EPriorityStandard ),             
       
   137             iObserver( aObserver ),
       
   138             iPhone( aPhone )
       
   139     {
       
   140     CSPLOGSTRING(CSPOBJECT, 
       
   141         "CSPEtelDtmfStopMonitor::CSPEtelDtmfStopMonitor()" );
       
   142     CActiveScheduler::Add( this );
       
   143     }
       
   144 
       
   145 // End of file