wlanutilities/wlansniffer/wlansnifferkeepalive/inc/wsfkeepalivetimer.h
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     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 #ifndef WSFKEEPALIVETIMER_H
       
    19 #define WSFKEEPALIVETIMER_H
       
    20 
       
    21 // System includes
       
    22  
       
    23 #include <e32base.h>
       
    24 
       
    25 // User includes
       
    26 
       
    27 // Forward declarations
       
    28  
       
    29 // External data types
       
    30 
       
    31 // Global function prototypes
       
    32  
       
    33 // Constants
       
    34 
       
    35 // Class declaration
       
    36 
       
    37 /**
       
    38  *  Timer interface class.
       
    39  *
       
    40  *  This is an interface class, which the Keepalive implementation needs
       
    41  *  to inherit in order to receive timer notifications.
       
    42  */
       
    43 class MWsfKeepaliveTimerNotify
       
    44     {
       
    45 public:
       
    46     
       
    47     /**
       
    48      * Pure virtual timer expiration function that needs to be
       
    49      * implemented in the Keepalive implementation class.
       
    50      * 
       
    51      * @param aError Status of the timer event
       
    52      */
       
    53     virtual void TimerExpired( TInt aError ) = 0;
       
    54     };
       
    55  
       
    56 /**
       
    57  *  Timer implementation.
       
    58  *  
       
    59  *  This is the actual timer implementation class.
       
    60  */
       
    61 class CWsfKeepaliveTimer: public CActive
       
    62 {
       
    63     // Friend classes:
       
    64 
       
    65 public:
       
    66     
       
    67     // Data types
       
    68 
       
    69     /** Constructors */
       
    70     
       
    71     /**
       
    72      * Two-phased constructor.
       
    73      * 
       
    74      * @param aNotify Timer expirations are notified to this class
       
    75      * @return New object allocated from heap
       
    76      */
       
    77     static CWsfKeepaliveTimer* NewL( MWsfKeepaliveTimerNotify& aNotify );
       
    78     
       
    79     /**> Destructor */
       
    80     virtual ~CWsfKeepaliveTimer();
       
    81 
       
    82 public:
       
    83 
       
    84     /**
       
    85      * Sets the timer to expire after the given interval.
       
    86      * 
       
    87      * @param aInterval Interval in microseconds
       
    88      */
       
    89     void After( TTimeIntervalMicroSeconds32 aInterval );
       
    90 
       
    91     /**
       
    92      * Stops the timer.
       
    93      */
       
    94     void Stop();
       
    95 
       
    96 protected:
       
    97     
       
    98 private:
       
    99     
       
   100     CWsfKeepaliveTimer( MWsfKeepaliveTimerNotify& aNotify );
       
   101 
       
   102     void ConstructL();
       
   103     
       
   104     void RunL();
       
   105     
       
   106     void DoCancel();
       
   107 
       
   108 private: // Data
       
   109 
       
   110     /**
       
   111      * Actual timer object
       
   112      */
       
   113     RTimer iTimer;
       
   114 
       
   115     /**
       
   116      * Timer expirations are notified to this class
       
   117      */
       
   118     MWsfKeepaliveTimerNotify& iNotify;
       
   119     };
       
   120 
       
   121 #endif // WSFKEEPALIVETIMER_H