wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlantimer.cpp
changeset 13 ab7247ff6ef9
equal deleted inserted replaced
0:c40eb8fe8501 13:ab7247ff6ef9
       
     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 the License "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:
       
    15 * This class implements timer services.
       
    16 *
       
    17 */
       
    18 
       
    19 /*
       
    20 * %version: 1 %
       
    21 */
       
    22 
       
    23 #include "wlantimer.h"
       
    24 #include "am_debug.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // C++ constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CWlanTimer::CWlanTimer( 
       
    33     const TCallBack& aTimerExpiredCB,
       
    34     const TCallBack& aTimerCancelledCB,
       
    35     const TCallBack& aTimerErrorCB ) :
       
    36     CTimer( CActive::EPriorityStandard ),
       
    37     iTimerExpiredCB( aTimerExpiredCB ),
       
    38     iTimerCancelledCB( aTimerCancelledCB ),
       
    39     iTimerErrorCB( aTimerErrorCB )
       
    40     {
       
    41     // No implementation required
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Symbian 2nd phase constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CWlanTimer::ConstructL()
       
    49     {
       
    50     CTimer::ConstructL();
       
    51     CActiveScheduler::Add( this );
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Static constructor.
       
    56 //
       
    57 // @return  Pointer to CWlanTimer instance.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CWlanTimer* CWlanTimer::NewL(  
       
    61     const TCallBack& aTimerExpiredCB,
       
    62     const TCallBack& aTimerCancelledCB,
       
    63     const TCallBack& aTimerErrorCB )
       
    64     {
       
    65     CWlanTimer* self = new (ELeave) CWlanTimer(
       
    66         aTimerExpiredCB,
       
    67         aTimerCancelledCB,
       
    68         aTimerErrorCB );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop( self );
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Destructor.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CWlanTimer::~CWlanTimer()
       
    80     {
       
    81     Cancel();
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // RunL.
       
    86 // Handles timer events.
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CWlanTimer::RunL()
       
    90     {
       
    91     switch( iStatus.Int() )
       
    92         {
       
    93         case KErrNone: // Timer expired
       
    94             iTimerExpiredCB.CallBack();
       
    95             break;
       
    96         case KErrCancel: // Timer cancelled
       
    97             DEBUG( "CWlanTimer::RunL() - timer cancelled" );
       
    98             iTimerCancelledCB.CallBack();
       
    99             break;
       
   100         default: // Timer error code
       
   101             DEBUG1( "CWlanTimer::RunL() - timer error (status: %d)",
       
   102                 iStatus.Int() );
       
   103             iTimerErrorCB.CallBack();
       
   104         }
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // Cancel timer.
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CWlanTimer::DoCancel()
       
   112     {
       
   113     CTimer::DoCancel();
       
   114     }