connectionmonitoring/connmon/connectionmonitor/src/connmondtmnoti.cpp
changeset 0 5a93021fdf25
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2006-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:  ConnMon Dual Transfer Mode watcher.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "connmondtmnoti.h"
       
    19 #include "ConnMonDef.h"
       
    20 #include "log.h"
       
    21 
       
    22 #include <pcktcs.h>
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CConnMonDtmNotifier::NewL
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CConnMonDtmNotifier* CConnMonDtmNotifier::NewL(
       
    31         RPacketService& aPacketService,
       
    32         MConnMonDtmNotifierObserver& aObserver )
       
    33     {
       
    34     CConnMonDtmNotifier* self = new( ELeave ) CConnMonDtmNotifier(
       
    35             aPacketService,
       
    36             aObserver );
       
    37 
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CConnMonDtmNotifier::CConnMonDtmNotifier
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CConnMonDtmNotifier::CConnMonDtmNotifier(
       
    50         RPacketService& aPacketService,
       
    51         MConnMonDtmNotifierObserver& aObserver )
       
    52         :
       
    53         CActive( EConnMonPriorityNormal ),
       
    54         iPacketService( aPacketService ),
       
    55         iMsClass( RPacketService::EMSClassUnknown ),
       
    56         iObserver( aObserver ),
       
    57         iSendEvents( EFalse )
       
    58     {
       
    59     CActiveScheduler::Add( this );
       
    60     }
       
    61 
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CConnMonDtmNotifier::~CConnMonDtmNotifier
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CConnMonDtmNotifier::~CConnMonDtmNotifier()
       
    68     {
       
    69     //LOGENTRFN("CConnMonDtmNotifier::~CConnMonDtmNotifier()")
       
    70     Cancel();
       
    71     //LOGEXITFN("CConnMonDtmNotifier::~CConnMonDtmNotifier()")
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CConnMonDtmNotifier::ConstructL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CConnMonDtmNotifier::ConstructL()
       
    80     {
       
    81     //LOGENTRFN("CConnMonDtmNotifier::ConstructL()")
       
    82 
       
    83     // Request current MS class from ETel
       
    84     TRequestStatus status;
       
    85     iPacketService.GetMSClass( status, iMsClass, iMaxMsClass );
       
    86     User::WaitForRequest( status );
       
    87 
       
    88     if ( status.Int() != KErrNone )
       
    89         {
       
    90         LOGIT1("CConnMonDtmNotifier: ERROR getting MSClass from ETel <%d>", status.Int())
       
    91         User::LeaveIfError( status.Int() );
       
    92         }
       
    93 
       
    94     // Request notification from ETel about MS class change
       
    95     iPacketService.NotifyMSClassChange( iStatus, iMsClass );
       
    96     SetActive();
       
    97 
       
    98     LOGIT("Created CConnMonDtmNotifier")
       
    99     //LOGEXITFN("CConnMonDtmNotifier::ConstructL()")
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CConnMonDtmNotifier::IsInDualMode
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 TBool CConnMonDtmNotifier::IsInDualMode() const
       
   108     {
       
   109     LOGIT1("CConnMonDtmNotifier::IsInDualMode: %d", iMsClass == RPacketService::EMSClassDualMode)
       
   110 
       
   111     return ( iMsClass == RPacketService::EMSClassDualMode );
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CConnMonDtmNotifier::Receive
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CConnMonDtmNotifier::Receive()
       
   119     {
       
   120     iSendEvents = ETrue;
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CConnMonDtmNotifier::CancelNotificatications
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void CConnMonDtmNotifier::CancelNotifications()
       
   128     {
       
   129     iSendEvents = EFalse;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CConnMonDtmNotifier::RunL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CConnMonDtmNotifier::RunL()
       
   137     {
       
   138     //LOGENTRFN("CConnMonDtmNotifier::RunL()")
       
   139 
       
   140     LOGIT(".")
       
   141     LOGIT1("RunL: CConnMonDtmNotifier, status <%d>", iStatus.Int())
       
   142 
       
   143     if ( KErrNone == iStatus.Int() )
       
   144         {
       
   145         if ( iSendEvents )
       
   146             {
       
   147             LOGIT("Server: CConnMonTelNotifier::RunL - Notifying observer")
       
   148             iObserver.DtmStateChanged();
       
   149             }
       
   150         // Request notification from ETel about MS class change
       
   151         iPacketService.NotifyMSClassChange( iStatus, iMsClass );
       
   152         SetActive();
       
   153         }
       
   154     else
       
   155         {
       
   156         // Log error and stop
       
   157         LOGIT1("Server: CConnMonDtmNotifier::RunL - Error <%d>", iStatus.Int())
       
   158         }
       
   159     //LOGEXITFN("CConnMonDtmNotifier::RunL()")
       
   160     }
       
   161 
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CConnMonDtmNotifier::DoCancel
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CConnMonDtmNotifier::DoCancel()
       
   168     {
       
   169     //LOGENTRFN("CConnMonDtmNotifier::DoCancel()")
       
   170     iPacketService.CancelAsyncRequest( EPacketNotifyMSClassChange );
       
   171     //LOGEXITFN("CConnMonDtmNotifier::DoCancel()")
       
   172     }
       
   173 
       
   174 // End-of-file