wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepalivetimer.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 * Timer implementation.
       
    16 */
       
    17 
       
    18 // System include files
       
    19 
       
    20 // User include files
       
    21 
       
    22 #include "wsfkeepalivetimer.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "wsfkeepalivetimerTraces.h"
       
    26 #endif
       
    27 
       
    28 // External function prototypes
       
    29 
       
    30 // Local constants
       
    31 
       
    32 // ======== LOCAL FUNCTIONS ========
       
    33 
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 CWsfKeepaliveTimer* CWsfKeepaliveTimer::NewL(
       
    37     MWsfKeepaliveTimerNotify& aNotify )
       
    38     {
       
    39     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_NEWL_ENTRY );
       
    40     
       
    41     CWsfKeepaliveTimer* me =
       
    42         new ( ELeave ) CWsfKeepaliveTimer( aNotify );
       
    43     CleanupStack::PushL( me );
       
    44     me->ConstructL();
       
    45     CleanupStack::Pop( me );
       
    46     
       
    47     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_NEWL_EXIT );
       
    48     return me;
       
    49     }
       
    50  
       
    51 CWsfKeepaliveTimer::~CWsfKeepaliveTimer()
       
    52     {   
       
    53     OstTraceFunctionEntry0( DUP1_CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_ENTRY );
       
    54 
       
    55     Cancel();
       
    56     iTimer.Close();
       
    57 
       
    58     OstTraceFunctionExit0( DUP1_CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_EXIT );
       
    59     }
       
    60  
       
    61 void CWsfKeepaliveTimer::After( TTimeIntervalMicroSeconds32 aInterval )
       
    62     {
       
    63     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_AFTER_ENTRY );
       
    64 
       
    65     // Cancel a (possibly) ongoing timer before starting new one
       
    66     Cancel();
       
    67     iTimer.After( iStatus, aInterval );
       
    68     SetActive();
       
    69 
       
    70     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_AFTER_EXIT );
       
    71     }
       
    72  
       
    73 void CWsfKeepaliveTimer::Stop()
       
    74     {
       
    75     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_STOP_ENTRY );
       
    76 
       
    77     iTimer.Cancel();
       
    78 
       
    79     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_STOP_EXIT );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Default constructor
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 CWsfKeepaliveTimer::CWsfKeepaliveTimer( MWsfKeepaliveTimerNotify& aNotify ) :
       
    87     CActive( EPriorityStandard ),
       
    88     iNotify( aNotify )
       
    89     {
       
    90     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_ENTRY );
       
    91     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_CWSFKEEPALIVETIMER_EXIT );
       
    92     }
       
    93  
       
    94 // ---------------------------------------------------------------------------
       
    95 // Leaving constructor
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CWsfKeepaliveTimer::ConstructL()
       
    99     {
       
   100     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_CONSTRUCTL_ENTRY );
       
   101  
       
   102     CActiveScheduler::Add( this );
       
   103     User::LeaveIfError( iTimer.CreateLocal() );
       
   104 
       
   105     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_CONSTRUCTL_EXIT );
       
   106     }
       
   107  
       
   108 // ---------------------------------------------------------------------------
       
   109 // Handles an active object's request completion event
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CWsfKeepaliveTimer::RunL()
       
   113     {
       
   114     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_RUNL_ENTRY );
       
   115     
       
   116     iNotify.TimerExpired( iStatus.Int() );
       
   117 
       
   118     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_RUNL_EXIT );
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // Implements cancellation of an outstanding request
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CWsfKeepaliveTimer::DoCancel()
       
   126     {
       
   127     OstTraceFunctionEntry0( CWSFKEEPALIVETIMER_DOCANCEL_ENTRY );
       
   128     
       
   129     iTimer.Cancel();
       
   130 
       
   131     OstTraceFunctionExit0( CWSFKEEPALIVETIMER_DOCANCEL_EXIT );
       
   132     }