wim/WimServer/inc/WimTimer.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  A timer class that calls the function TimerExpired for the 
       
    15 *               registered classes of type MWimTimerListener
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CWIMTIMER_H
       
    22 #define CWIMTIMER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 // Interface for the listener
       
    28 class MWimTimerListener
       
    29     {
       
    30     public:
       
    31         virtual void TimerExpired() = 0;
       
    32         virtual ~MWimTimerListener(){}
       
    33     };  
       
    34 
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  Timer class.
       
    40 *  
       
    41 *  @since Series60 2.6
       
    42 */
       
    43 class CWimTimer : public CActive, public MBeating
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46         
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         */
       
    50         static CWimTimer* NewL( MWimTimerListener* aTimerListener );
       
    51         
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         virtual ~CWimTimer();
       
    56 
       
    57     public: // New functions
       
    58         
       
    59         /**
       
    60         * Set timeout value for closing WIM connection
       
    61         * @param aMessage Client message
       
    62         * @return void
       
    63         */
       
    64         void SetCloseAfter( const RMessage2& aMessage );
       
    65 
       
    66         /**
       
    67         * Resets timer
       
    68         * @return void
       
    69         */
       
    70         void ResetTimer();
       
    71 
       
    72         /**
       
    73         * Time remaining. Write value to client.
       
    74         * @return void
       
    75         */
       
    76         void TimeRemainingL( const RMessage2& aMessage ) const;
       
    77         
       
    78         /**
       
    79         * Time reamining, Used in Server side
       
    80         */
       
    81         TInt TimeRemaining() const;
       
    82         
       
    83         /**
       
    84         * Get delay set by SetCloseAfter. Write value to client.
       
    85         * @return void
       
    86         */
       
    87         void GetCloseAfterL( const RMessage2& aMessage ) const;
       
    88 
       
    89     private:
       
    90 
       
    91         /**
       
    92         * C++ default constructor.
       
    93         */
       
    94         CWimTimer();
       
    95 
       
    96         /**
       
    97         * By default Symbian 2nd phase constructor is private.
       
    98         */
       
    99         void ConstructL( MWimTimerListener* aTimerListener );
       
   100 
       
   101         /**
       
   102         * From CActive Handles an active object’s request completion event
       
   103         * @return void
       
   104         */
       
   105         void RunL();
       
   106 
       
   107         /**
       
   108         * From CActive Cancellation of an outstanding request
       
   109         * @return void
       
   110         */
       
   111         void DoCancel();
       
   112 
       
   113         /**
       
   114         * Set timeout value for closing WIM connection
       
   115         * @param aCloseAfter Timeout value in seconds
       
   116         * @return void
       
   117         */
       
   118         void DoSetCloseAfter( TInt aCloseAfter );
       
   119 
       
   120         /**
       
   121         * From MBeating. Timer beat has occurred, increase beat counter.
       
   122         * @return void
       
   123         */
       
   124         void Beat();
       
   125 
       
   126         /**
       
   127         * From MBeating. Synchronize.
       
   128         * @return void
       
   129         */
       
   130         void Synchronize();
       
   131 
       
   132         /**
       
   133         * Start heart beating
       
   134         * @return void
       
   135         */
       
   136         void StartHeartBeat();
       
   137 
       
   138     private:    // Data
       
   139         // Delay in microseconds
       
   140         TTimeIntervalMicroSeconds32 iDelay;
       
   141         // Interface for calling listeners. Not owned.
       
   142         MWimTimerListener*          iTimerListener;
       
   143         // Asynchronous timer
       
   144         RTimer                      iTimer;
       
   145         // Pointer to Heartbeat instance. Owned.
       
   146         CHeartbeat*                 iHeartbeat;
       
   147         // Heartbeat count
       
   148         TUint                       iHeartBeatCount;
       
   149          
       
   150     };
       
   151 
       
   152 #endif      // CWIMTIMER_H
       
   153 
       
   154 // End of File