mmserv/tms/tmscallserver/src/cspeteldtmfstopmonitor.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 <gsmerror.h>
       
    20 #include "cspeteldtmfstopmonitor.h"
       
    21 #include "tmsutility.h"
       
    22 #include "cspdtmfprovider.h"
       
    23 #include "cspdtmfprovider.h"
       
    24 
       
    25 using namespace TMS;
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // TMSEtelDtmfStopMonitor::NewL.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 TMSEtelDtmfStopMonitor* TMSEtelDtmfStopMonitor::NewL(TMSDTMFProvider& aObserver,
       
    32         RMobilePhone& aPhone)
       
    33     {
       
    34     TRACE_PRN_FN_EXT;
       
    35     TMSEtelDtmfStopMonitor* self = new (ELeave) TMSEtelDtmfStopMonitor(
       
    36             aObserver, aPhone);
       
    37     TRACE_PRN_FN_EXT;
       
    38     return self;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // Constructs the monitor.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 TMSEtelDtmfStopMonitor::TMSEtelDtmfStopMonitor(TMSDTMFProvider& aObserver,
       
    46         RMobilePhone& aPhone) :
       
    47     CActive(EPriorityStandard),
       
    48     iObserver(aObserver),
       
    49     iPhone(aPhone)
       
    50     {
       
    51     TRACE_PRN_FN_ENT;
       
    52     CActiveScheduler::Add(this);
       
    53     TRACE_PRN_FN_EXT;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // Destructs the object by canceling first ongoing monitoring.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 TMSEtelDtmfStopMonitor::~TMSEtelDtmfStopMonitor()
       
    61     {
       
    62     TRACE_PRN_FN_ENT;
       
    63     Cancel();
       
    64     TRACE_PRN_FN_EXT;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // Starts the monitor.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void TMSEtelDtmfStopMonitor::StartMonitoring()
       
    72     {
       
    73     TRACE_PRN_FN_ENT;
       
    74     if (!IsActive())
       
    75         {
       
    76         iStatus = KRequestPending;
       
    77         iPhone.NotifyStopInDTMFString(iStatus);
       
    78         SetActive();
       
    79         }
       
    80     TRACE_PRN_FN_EXT;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // From CActive.
       
    85 // Handles line status change notifying.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void TMSEtelDtmfStopMonitor::RunL()
       
    89     {
       
    90     TRACE_PRN_FN_ENT;
       
    91     gint err = iStatus.Int();
       
    92     TRACE_PRN_N1(_L("**TMS TMSEtelDtmfStopMonitor::RunL: status: %d"), err);
       
    93 
       
    94     if (err != KErrCancel && err != KErrServerTerminated)
       
    95         {
       
    96         TChar tone = NULL;
       
    97         TMSCCPDTMFObserver::TCCPDtmfEvent event =
       
    98                 TMSCCPDTMFObserver::ECCPDtmfStopInDtmfString;
       
    99         iObserver.NotifyDTMFEvent(event, err, tone);
       
   100         }
       
   101     else
       
   102         {
       
   103         TRACE_PRN_N1(_L("**TMS TMSEtelDtmfStopMonitor::RunL: Error \
       
   104                        from RMobilePhone: %d"),iStatus.Int());
       
   105         }
       
   106 
       
   107     // Continue if not in offline mode
       
   108     if (err != KErrGsmOfflineOpNotAllowed && err != KErrCancel
       
   109             && err != KErrNotSupported)
       
   110         {
       
   111         StartMonitoring();
       
   112         }
       
   113     TRACE_PRN_FN_EXT;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // From CActive
       
   118 // Canceling functionality.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void TMSEtelDtmfStopMonitor::DoCancel()
       
   122     {
       
   123     TRACE_PRN_FN_ENT;
       
   124     if (iStatus == KRequestPending)
       
   125         {
       
   126         iPhone.CancelAsyncRequest(EMobilePhoneNotifyStopInDTMFString);
       
   127         }
       
   128     TRACE_PRN_FN_EXT;
       
   129     }
       
   130 
       
   131 // End of file