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