convergedcallengine/csplugin/src/cspeteldtmfmonitor.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 CSPEtelDtmfMonitor
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <mccpdtmfobserver.h>
       
    21 #include <rmmcustomapi.h>
       
    22 #include <gsmerror.h>
       
    23 
       
    24 #include "cspeteldtmfmonitor.h"
       
    25 #include "csplogger.h"
       
    26 #include "cspdtmfprovider.h"
       
    27 #include "cspconsts.h"
       
    28 #include "cspdtmfprovider.h"
       
    29 
       
    30 
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CSPEtelDtmfMonitor::NewL.
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CSPEtelDtmfMonitor* CSPEtelDtmfMonitor::NewL( 
       
    37                                         CSPDTMFProvider& aObserver, 
       
    38                                         RMmCustomAPI& aMmCustom ) 
       
    39     {
       
    40     CSPLOGSTRING(CSPOBJECT, 
       
    41         "CSPEtelDtmfMonitor::NewL()" );
       
    42     CSPEtelDtmfMonitor* self = new ( ELeave ) CSPEtelDtmfMonitor( 
       
    43                                         aObserver, aMmCustom );
       
    44     return self;    
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Destructs the object by canceling first ongoing monitoring.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CSPEtelDtmfMonitor::~CSPEtelDtmfMonitor( )
       
    53     {
       
    54     CSPLOGSTRING(CSPOBJECT, 
       
    55         "CSPEtelDtmfMonitor::~CSPEtelDtmfMonitor()" );
       
    56     Cancel();
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Starts the monitor.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CSPEtelDtmfMonitor::StartMonitoring()
       
    64     {
       
    65     CSPLOGSTRING(CSPINT, 
       
    66         "CSPEtelDtmfMonitor::StartMonitoring()" );
       
    67 
       
    68     if ( !IsActive() )
       
    69         {
       
    70         CSPLOGSTRING( CSPINT, 
       
    71             "CSP: CSPEtelDtmfMonitor::StartMonitoring: Request \
       
    72                     iMmCustom.NotifyDTMFEvent( iStatus, iEventData )" );
       
    73         iMmCustom.NotifyDtmfEvent( iStatus, iEventData );
       
    74         SetActive();
       
    75         }
       
    76     else
       
    77         {
       
    78         CSPLOGSTRING( CSPERROR, 
       
    79             "CSP: CSPEtelDtmfMonitor::StartMonitoring: Already active" );
       
    80         }
       
    81     }
       
    82 // ---------------------------------------------------------------------------
       
    83 // From CActive.
       
    84 // Handles line status change notifying.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CSPEtelDtmfMonitor::RunL()
       
    88     {
       
    89     TInt err = iStatus.Int();
       
    90     CSPLOGSTRING2( CSPREQEND, 
       
    91         "CSPEtelDtmfMonitor::RunL: status: %d", err );
       
    92     
       
    93     if ( err == KErrNone )
       
    94         {
       
    95         MCCPDTMFObserver::TCCPDtmfEvent event;
       
    96         if ( iEventData.iEvent == RMmCustomAPI::EDtmfStart 
       
    97              && iEventData.iType == RMmCustomAPI::EDtmfManual )
       
    98             {
       
    99             event = MCCPDTMFObserver::ECCPDtmfManualStart;
       
   100             }
       
   101         else if ( iEventData.iEvent == RMmCustomAPI::EDtmfStart 
       
   102              && iEventData.iType == RMmCustomAPI::EDtmfSequence )
       
   103             {
       
   104             event = MCCPDTMFObserver::ECCPDtmfSequenceStart;
       
   105             }
       
   106         else if ( iEventData.iEvent == RMmCustomAPI::EDtmfStop 
       
   107              && iEventData.iType == RMmCustomAPI::EDtmfManual )
       
   108             {
       
   109             event = MCCPDTMFObserver::ECCPDtmfManualStop;
       
   110             }
       
   111         else if ( iEventData.iEvent == RMmCustomAPI::EDtmfStop 
       
   112              && iEventData.iType == RMmCustomAPI::EDtmfSequence )
       
   113             {
       
   114             event = MCCPDTMFObserver::ECCPDtmfSequenceStop;
       
   115             }
       
   116         else if ( iEventData.iEvent == RMmCustomAPI::EDtmfAbort 
       
   117              && iEventData.iType == RMmCustomAPI::EDtmfManual )
       
   118             {
       
   119             event = MCCPDTMFObserver::ECCPDtmfManualAbort;
       
   120             }
       
   121         else if ( iEventData.iEvent == RMmCustomAPI::EDtmfAbort 
       
   122              && iEventData.iType == RMmCustomAPI::EDtmfSequence )
       
   123             {
       
   124             event = MCCPDTMFObserver::ECCPDtmfSequenceAbort;
       
   125             }
       
   126         else
       
   127             {
       
   128             // Unknown event
       
   129             CSPLOGSTRING3( CSPERROR, 
       
   130                 "CSPEtelDtmfMonitor::RunL: Unknown event = %¨d, type = %d", 
       
   131                     iEventData.iEvent, iEventData.iType );
       
   132             
       
   133             // Refresh and return (no observer notfiying).
       
   134             StartMonitoring();
       
   135             return;
       
   136             }
       
   137         
       
   138         iObserver.NotifyDTMFEvent( event, err, iEventData.iTone );
       
   139         }
       
   140     else
       
   141         {
       
   142         CSPLOGSTRING2( CSPERROR, "CSPEtelDtmfMonitor::RunL: Error \
       
   143                     from DTMF: %d", err );
       
   144         }
       
   145     
       
   146     // Continue if not in offline mode
       
   147     if ( err != KErrGsmOfflineOpNotAllowed && err != KErrCancel 
       
   148          && err != KErrNotSupported )
       
   149         {
       
   150         StartMonitoring();
       
   151         }
       
   152     CSPLOGSTRING( CSPREQEND, "CSPEtelDtmfMonitor::RunL End of RunL." );
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // From CActive
       
   157 // Canceling functionality.
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 void CSPEtelDtmfMonitor::DoCancel()
       
   161     {
       
   162     if ( iStatus == KRequestPending )
       
   163         {
       
   164         CSPLOGSTRING( CSPINT, 
       
   165             "CSPEtelDtmfMonitor::DoCancel Canceling pending request.." );
       
   166         iMmCustom.CancelAsyncRequest( ECustomNotifyDtmfEventIPC ); 
       
   167         }
       
   168     }
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // Constructs the monitor.
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 CSPEtelDtmfMonitor::CSPEtelDtmfMonitor(
       
   176             CSPDTMFProvider& aObserver, 
       
   177             RMmCustomAPI& aMmCustom ) : 
       
   178                 CActive( EPriorityStandard ),             
       
   179                 iObserver( aObserver ),
       
   180                 iMmCustom( aMmCustom )
       
   181     {
       
   182     CSPLOGSTRING(CSPOBJECT, 
       
   183         "CSPEtelDtmfMonitor::CSPEtelDtmfMonitor()" );
       
   184     CActiveScheduler::Add( this );
       
   185     }
       
   186     
       
   187 
       
   188 // End of file