mmserv/tms/tmscallserver/src/cspeteldtmfmonitor.cpp
changeset 14 80975da52420
parent 12 5a06f39ad45b
child 16 43d09473c595
child 19 4a629bc82c5e
equal deleted inserted replaced
12:5a06f39ad45b 14:80975da52420
     1 /*
       
     2  * Copyright (c) 2009 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: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #include <mccpdtmfobserver.h>
       
    19 #include <rmmcustomapi.h>
       
    20 #include <gsmerror.h>
       
    21 #include "cspeteldtmfmonitor.h"
       
    22 #include "tmsutility.h"
       
    23 #include "cspdtmfprovider.h"
       
    24 #include "cspdtmfprovider.h"
       
    25 
       
    26 using namespace TMS;
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // TMSEtelDtmfMonitor::NewL.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 TMSEtelDtmfMonitor* TMSEtelDtmfMonitor::NewL(TMSDTMFProvider& aObserver,
       
    33         RMmCustomAPI& aMmCustom)
       
    34     {
       
    35     TRACE_PRN_FN_ENT;
       
    36     TMSEtelDtmfMonitor* self = new (ELeave) TMSEtelDtmfMonitor(aObserver,
       
    37             aMmCustom);
       
    38     TRACE_PRN_FN_EXT;
       
    39     return self;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // Destructs the object by canceling first ongoing monitoring.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 TMSEtelDtmfMonitor::~TMSEtelDtmfMonitor()
       
    47     {
       
    48     TRACE_PRN_FN_ENT;
       
    49     Cancel();
       
    50     TRACE_PRN_FN_EXT;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // Starts the monitor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void TMSEtelDtmfMonitor::StartMonitoring()
       
    58     {
       
    59     TRACE_PRN_FN_ENT;
       
    60     if (!IsActive())
       
    61         {
       
    62         iStatus = KRequestPending;
       
    63         iMmCustom.NotifyDtmfEvent(iStatus, iEventData);
       
    64         SetActive();
       
    65         }
       
    66     TRACE_PRN_FN_EXT;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // From CActive.
       
    71 // Handles line status change notifying.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void TMSEtelDtmfMonitor::RunL()
       
    75     {
       
    76     TRACE_PRN_FN_ENT;
       
    77     TInt err = iStatus.Int();
       
    78     TRACE_PRN_N1(_L("**TMS TMSEtelDtmfMonitor::RunL: status:%d"), err);
       
    79 
       
    80     if (err == KErrNone)
       
    81         {
       
    82         TMSCCPDTMFObserver::TCCPDtmfEvent event;
       
    83         if (iEventData.iEvent == RMmCustomAPI::EDtmfStart
       
    84                 && iEventData.iType == RMmCustomAPI::EDtmfManual)
       
    85             {
       
    86             event = TMSCCPDTMFObserver::ECCPDtmfManualStart;
       
    87             }
       
    88         else if (iEventData.iEvent == RMmCustomAPI::EDtmfStart
       
    89                 && iEventData.iType == RMmCustomAPI::EDtmfSequence)
       
    90             {
       
    91             event = TMSCCPDTMFObserver::ECCPDtmfSequenceStart;
       
    92             }
       
    93         else if (iEventData.iEvent == RMmCustomAPI::EDtmfStop
       
    94                 && iEventData.iType == RMmCustomAPI::EDtmfManual)
       
    95             {
       
    96             event = TMSCCPDTMFObserver::ECCPDtmfManualStop;
       
    97             }
       
    98         else if (iEventData.iEvent == RMmCustomAPI::EDtmfStop
       
    99                 && iEventData.iType == RMmCustomAPI::EDtmfSequence)
       
   100             {
       
   101             event = TMSCCPDTMFObserver::ECCPDtmfSequenceStop;
       
   102             }
       
   103         else if (iEventData.iEvent == RMmCustomAPI::EDtmfAbort
       
   104                 && iEventData.iType == RMmCustomAPI::EDtmfManual)
       
   105             {
       
   106             event = TMSCCPDTMFObserver::ECCPDtmfManualAbort;
       
   107             }
       
   108         else if (iEventData.iEvent == RMmCustomAPI::EDtmfAbort
       
   109                 && iEventData.iType == RMmCustomAPI::EDtmfSequence)
       
   110             {
       
   111             event = TMSCCPDTMFObserver::ECCPDtmfSequenceAbort;
       
   112             }
       
   113         else
       
   114             {
       
   115             // Refresh and return (no observer notfiying).
       
   116             TRACE_PRN_N2(_L("**TMS TMSEtelDtmfMonitor::RunL: Unknown event \
       
   117                     = %¨d, type = %d"), iEventData.iEvent,iEventData.iType);
       
   118             StartMonitoring();
       
   119             return;
       
   120             }
       
   121 
       
   122         iObserver.NotifyDTMFEvent(event, err, iEventData.iTone);
       
   123         }
       
   124     else
       
   125         {
       
   126         TRACE_PRN_N1(_L("**TMS TMSEtelDtmfMonitor::RunL: Error \
       
   127                 from DTMF: %d"),err);
       
   128         }
       
   129 
       
   130     // Continue if not in offline mode
       
   131     if (err != KErrGsmOfflineOpNotAllowed && err != KErrCancel
       
   132             && err != KErrNotSupported)
       
   133         {
       
   134         StartMonitoring();
       
   135         }
       
   136     TRACE_PRN_FN_EXT;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // From CActive
       
   141 // Canceling functionality.
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void TMSEtelDtmfMonitor::DoCancel()
       
   145     {
       
   146     TRACE_PRN_FN_ENT;
       
   147     if (iStatus == KRequestPending)
       
   148         {
       
   149         iMmCustom.CancelAsyncRequest(ECustomNotifyDtmfEventIPC);
       
   150         }
       
   151     TRACE_PRN_FN_EXT;
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // Constructs the monitor.
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 TMSEtelDtmfMonitor::TMSEtelDtmfMonitor(TMSDTMFProvider& aObserver,
       
   159         RMmCustomAPI& aMmCustom) :
       
   160     CActive(EPriorityStandard),
       
   161     iObserver(aObserver),
       
   162     iMmCustom(aMmCustom)
       
   163     {
       
   164     TRACE_PRN_FN_ENT;
       
   165     CActiveScheduler::Add(this);
       
   166     TRACE_PRN_FN_EXT;
       
   167     }
       
   168 
       
   169 // End of file