multimediacommsengine/mmcesrv/mmceserver/inc/mceexpirationhandler.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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:    This header file is included by the subsystems which are
       
    15 *                  using timer services, but are not responsible for creating
       
    16 *                  the CTimerManager instance.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __MCETIMER_H__
       
    23 #define __MCETIMER_H__
       
    24 
       
    25 // INCLUDES
       
    26 #include <e32def.h>
       
    27 
       
    28 /// Every timer is associated with an identifier of this type.
       
    29 /// When a timer is set, TMceTimerId is returned to the user of the Lightweight
       
    30 /// timer subsystem.
       
    31 /// When a timer expires, its TMceTimerId is passed in the callback.
       
    32 /// If the user wishes to stop or adjust a certain timer, it has to pass the
       
    33 /// TMceTimerId of the timer in question to the Lightweight timer subsystem.
       
    34 typedef TUint32 TMceTimerId;
       
    35 
       
    36 // CLASS DEFINITION
       
    37 /**
       
    38  * When a timer expires, this interface is called by the Ligthweight timer
       
    39  * subsystem.
       
    40  */
       
    41 class MMCEExpirationHandler
       
    42 	{
       
    43 	public: // Constructors and destructor
       
    44 
       
    45 		/// Virtual destructor
       
    46 		virtual ~MMCEExpirationHandler() {}
       
    47 
       
    48 	public: // Abstract methods
       
    49 
       
    50 		/**
       
    51 		 * Indicates that a timer has expired.
       
    52 		 *
       
    53 		 * @param aTimerId Identifies the expired timer
       
    54 		 * @param aTimerParam User specified value which was given when the timer
       
    55 		 *	was set. It can be used to identify the timer in case multiple timers
       
    56 		 *  are running simultaneously. Value is NULL if the timer was set using
       
    57 		 *  CTimerManager::StartL() without parameter aTimerParam. Ownership isn't
       
    58 	     *  transferred.
       
    59 		 */
       
    60 		virtual void TimerExpiredL( TMceTimerId aTimerId, TAny* aTimerParam ) = 0;
       
    61 	};
       
    62 
       
    63 
       
    64 // CLASS DEFINITION
       
    65 /**
       
    66  * MMceTimerManager provides methods for starting, stopping and adjusting timers.
       
    67  */
       
    68 class MMceTimerManager
       
    69 	{
       
    70 	public: // Enumerations
       
    71 
       
    72 		/// This exists for backward compatibility
       
    73 		enum TMceTimerIdValues
       
    74 			{
       
    75 			/// TimerId that is never used with a valid timer
       
    76 			KNoSuchTimer = 0
       
    77 			};
       
    78 
       
    79 	public: // Constructors and destructor
       
    80 
       
    81 		/// Virtual destructor
       
    82 		virtual ~MMceTimerManager() {}
       
    83 
       
    84 	public:	// Abstract methods
       
    85 
       
    86 		/**
       
    87 		 * Creates a new timer and starts it.
       
    88 		 *
       
    89 		 * @pre aObserver != NULL
       
    90 		 * @see See also this method 'MMCEExpirationHandler::TimerExpiredL'
       
    91 		 *
       
    92 		 * @param aObserver	IN: Callback to use when timer expires. Ownership is
       
    93 		 *	not transferred.
       
    94 		 * @param aMilliseconds	Timer duration in milliseconds (with 32 bits, the
       
    95 		 *	max value is ~50 days)
       
    96 		 * @return value TimerId value identifying the new timer
       
    97 		 *
       
    98 		 * In case of an error, this function leaves.
       
    99 		 */
       
   100 		virtual TMceTimerId StartL( MMCEExpirationHandler* aObserver,
       
   101 							     TUint aMilliseconds ) = 0;
       
   102 							     
       
   103 		/**
       
   104 		 * Creates a new timer and starts it.
       
   105 		 *
       
   106 		 * @pre aObserver != NULL
       
   107 		 * @see See also this method 'MMCEExpirationHandler::TimerExpiredL'
       
   108 		 *
       
   109 		 * @param aObserver	IN: Callback to use when timer expires. Ownership is
       
   110 		 *	not transferred.
       
   111 		 * @param aMilliseconds	Timer duration in milliseconds (with 32 bits, the
       
   112 		 *	max value is ~50 days)
       
   113 		 * @param aTimerParam User specified value which will be passed to the
       
   114 		 *	aObserver function MMCEExpirationHandler::TimerExpiredL() when the timer
       
   115 		 *	expires. Ownership isn't transferred.
       
   116 		 * @return value TimerId value identifying the new timer
       
   117 		 *
       
   118 		 * In case of an error, this function leaves.
       
   119 		 */
       
   120 		virtual TMceTimerId StartL( MMCEExpirationHandler* aObserver,
       
   121 							     TUint aMilliseconds,
       
   122 							     TAny* aTimerParam ) = 0;							     
       
   123 
       
   124 		/**
       
   125 		 * Stops the specified timer.
       
   126 		 *
       
   127 		 * This function doesn't leave in case of error, as it is thought that this
       
   128 		 * function is usually also called from destructors.
       
   129 		 *
       
   130 		 * @param aTimerId Identifies the timer to be stopped
       
   131 		 * @return value KErrNone: successful
       
   132 	     *               KErrNotFound : no such timer exists
       
   133 		 */
       
   134 		virtual TInt Stop( TMceTimerId aTimerId ) = 0;
       
   135 
       
   136 		/**
       
   137 		 * Checks if there exists a timer which hasn't expired yet, with the
       
   138 		 * specified TimerId.
       
   139 		 *
       
   140 		 * @param aTimerId Identifies the timer
       
   141 		 * @return value ETrue: timer exists, KFalse: no such timer
       
   142 		 */
       
   143 		virtual TBool IsRunning( TMceTimerId aTimerId ) const = 0;
       
   144 
       
   145 	};
       
   146 
       
   147 #endif // __MCETIMER_H__
       
   148 
       
   149