resourcemgmt/hwresourcesmgr/server/inc/HWRMPluginHandler.h
changeset 0 4e1aa6a622a0
child 20 1ddbe54d0645
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef HWRMPLUGINHANDLER_H
       
    22 #define HWRMPLUGINHANDLER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include "HWRMPluginService.h"
       
    27 #include "HWRMPluginTransactionList.h"
       
    28 #include "HWRMGenericTimer.h"
       
    29 
       
    30 // CONSTANTS
       
    31 // None
       
    32 
       
    33 // MACROS
       
    34 // None
       
    35 
       
    36 // DATA TYPES
       
    37 
       
    38 // FUNCTION PROTOTYPES
       
    39 // None
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CHWRMService;
       
    43 
       
    44 // CLASS DECLARATIONS
       
    45 
       
    46 /**
       
    47  *  Callback interface for the server side plugin handler
       
    48  */
       
    49  class MHWRMIndicationHandler
       
    50      {
       
    51      public:
       
    52 
       
    53          /**
       
    54          * Method to return events from plugin handler
       
    55          *
       
    56          * @param aId  The indication ID
       
    57          * @param aData  Data associated with the indication 
       
    58          *
       
    59          */
       
    60          virtual void ProcessIndicationL( const TUint32 aId, TDesC8& aData ) = 0;
       
    61      };
       
    62 
       
    63 /**
       
    64 * This class contains ongoing plugin operation data.
       
    65 * It is used as a struct.
       
    66 */
       
    67 class THWRMTransactionData : public THWRMPluginTransactionListItem
       
    68     {
       
    69     public:
       
    70     
       
    71 	    CHWRMService*     iCompletionCallback; // Pointer to currently using service. Not owned.
       
    72 	    TTime             iObsoletionTime;     // Time after which the transaction is obsolete
       
    73 
       
    74         /**
       
    75 	    * Convenience constructor
       
    76 	    */
       
    77 	    THWRMTransactionData(CHWRMService* aCompletionCallback, 
       
    78 	                         TUint8 aTransId, 
       
    79 	                         TInt aCommandId,
       
    80 	                         const TTime& aObsoletionTime)
       
    81 	        : THWRMPluginTransactionListItem(aTransId, aCommandId),
       
    82 	        iCompletionCallback(aCompletionCallback),
       
    83 	        iObsoletionTime(aObsoletionTime)
       
    84 	            {
       
    85 	            };
       
    86 	            
       
    87 	    /**
       
    88 	    * Virtual destructor.
       
    89 	    */
       
    90 	    virtual ~THWRMTransactionData()
       
    91 	        {
       
    92 	        // iCompletionCallback not owned so not cleaned. Just NULL it to make pc-lint happy.
       
    93 	        iCompletionCallback = NULL;
       
    94 	        };
       
    95     };
       
    96     
       
    97 /**
       
    98 *  Hardware Resource Manager server side plugin
       
    99 *  handler implementation.
       
   100 *
       
   101 */
       
   102 class CHWRMPluginHandler : public CBase,
       
   103                            public MHWRMPluginCallback,
       
   104                            public MHWRMGenericTimerCallback
       
   105                                  
       
   106     {
       
   107     public: // Constructors and Destructor
       
   108     
       
   109         /**
       
   110         * Constructor method for instance.
       
   111         *
       
   112         * @param aMatch Determines the API that the loaded plugin implements.
       
   113         * @param aRequestTimeout Timeout in microseconds for requests
       
   114         */
       
   115         static CHWRMPluginHandler* NewL(const TDesC8& aMatch, TInt aRequestTimeout);
       
   116 
       
   117         /**
       
   118         * Destructor.
       
   119         */
       
   120         virtual ~CHWRMPluginHandler();
       
   121     
       
   122     public: // New functions
       
   123 
       
   124         /**
       
   125         * Method to invoke a particular command in the plugin.
       
   126         * Only one concurrent request is supported, will leave
       
   127         * with KErrNotSupported if request is attempted while
       
   128         * another is executing
       
   129         *
       
   130         * @param aCommandId          Command ID
       
   131         * @param aData               Data associated with command
       
   132         * @param aCompletionCallback Callback for completion.
       
   133         *                            If NULL, no callback is attempted.
       
   134         * @return Transaction ID (can be used later to cancel)
       
   135         *         Returns zero if transaction was already completed.
       
   136         */
       
   137         TUint8 ProcessCommandL( TInt aCommandId,
       
   138                               TDesC8& aData,
       
   139                               CHWRMService* aCompletionCallback);
       
   140 
       
   141         /**
       
   142         * Method to cancel currently executing command
       
   143         */
       
   144         void CancelCommandL( TUint8 aTransId );
       
   145 
       
   146 		/**
       
   147 		* Registers a handler for receiving HWRM plug-in indications
       
   148 		*
       
   149 		* @param aCallback  The indication handler to be registered
       
   150 		*/
       
   151         void RegisterForIndications(MHWRMIndicationHandler* aCallback);
       
   152         
       
   153         /**
       
   154 		* Deregisters handlers for receiving HWRM plug-in indications
       
   155 		*
       
   156 		* @param aCallback  The indication handler to be deregistered		
       
   157 		*/
       
   158 		void DeregisterForIndications(MHWRMIndicationHandler* aCallback);	
       
   159         
       
   160     	// MHWRMPluginCallback callback methods
       
   161     	
       
   162         /**
       
   163         * Method to return data in response to a message from a HWRM plugin.
       
   164         *
       
   165         * @param aCommandId Command identifier
       
   166         * @param aTransId   Unique transcation identifier
       
   167         * @param aData      Data returned from call
       
   168         *                   Since none of the commands require return value,
       
   169         *                   this package contains standard TInt error code.
       
   170         */
       
   171         void ProcessResponseL( TInt aCommandId,
       
   172                                TUint8 aTransId, 
       
   173                                TDesC8& aData ); 
       
   174         /**
       
   175          * Method to return indications from HWRM plugin.
       
   176          *
       
   177          * @param aIndId An indication ID
       
   178          * @param aData  Data associated with the event ID. 
       
   179          */
       
   180  		void EventL( const TUint32 aIndId, TDesC8& aData );
       
   181                                
       
   182     	// From MHWRMGenericTimerCallback    	
       
   183     	virtual void GenericTimerFired(TInt aTimerId, TBool aCutOff);
       
   184 
       
   185     private: 
       
   186     
       
   187         /**
       
   188         * C++ default constructor.
       
   189         * @param aRequestTimeout Timeout in microseconds for requests
       
   190         */
       
   191         CHWRMPluginHandler(TInt aRequestTimeout);
       
   192         
       
   193         /**
       
   194         * This 2nd phase constructor.
       
   195         *
       
   196         * @param aMatch Matching parameter used to determine correct 
       
   197         *               ECom implemetation
       
   198         */
       
   199         void ConstructL( const TDesC8& aMatch );
       
   200         
       
   201 	private:   // data
       
   202 	
       
   203 	    CHWRMPluginService*         iPlugin;           // Reference to plugin
       
   204 	    TUint8                      iTransIdCounter;   // Counter to create aTransIds
       
   205         CHWRMPluginTransactionList*	iTransactionList;  // List of open transactions       
       
   206         CHWRMGenericTimer*          iPluginTimer;      // Plugin call timeout timer.
       
   207         TTimeIntervalMicroSeconds32 iRequestTimeout;   // Maximum time request can be open.
       
   208 
       
   209         RPointerArray<MHWRMIndicationHandler> iIndicationCallbacks; // elements not owned
       
   210     };
       
   211 
       
   212 #endif  // HWRMPLUGINHANDLER_H
       
   213             
       
   214 // End of File