sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // e32\include\d32resmanus.h
sl@0: // 
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @publishedPartner
sl@0:  @released
sl@0: */
sl@0: 
sl@0: 
sl@0: #ifndef __D32RESMANUS_H__
sl@0: #define __D32RESMANUS_H__
sl@0: #include <e32cmn.h>
sl@0: #include <e32ver.h>
sl@0: 
sl@0: #include <drivers/resource_category.h>
sl@0: 
sl@0: // Name lengths repesent byte length (2 bytes per character for Unicode)
sl@0: #define MAX_RESOURCE_NAME_LENGTH	32 // 8-bit operation
sl@0: #define MAX_NAME_LENGTH_IN_RESMAN	32 // Maximum length of 8-bit name in Resource Controller
sl@0: #define MAX_CLIENT_NAME_LENGTH		256 // 8-bit operation
sl@0: 
sl@0: #ifdef RESOURCE_MANAGER_SIMULATED_PSL
sl@0: #define LEVEL_GAP_REQUIRED_FOR_ASYNC_TESTING 10  // Semi-arbitrary
sl@0: #define LEVEL_GAP_REQUIRED_FOR_SHARED_TESTING 3  // Semi-arbitrary
sl@0: #endif
sl@0: 
sl@0: //Structure to pass the dependency information
sl@0: #ifndef __KERNEL_MODE__
sl@0: struct SResourceDependencyInfo
sl@0: 	{
sl@0: 	TUint iResourceId;
sl@0: 	TUint8 iDependencyPriority;
sl@0: 	};
sl@0: #endif
sl@0: 
sl@0: struct TCapsDevResManUs
sl@0:     {
sl@0:     /**
sl@0:      * The device version
sl@0:      */
sl@0:     TVersion version;
sl@0:     };
sl@0: 
sl@0: struct TResourceInfo
sl@0: 	{
sl@0: 	TBuf8<MAX_RESOURCE_NAME_LENGTH>iName;
sl@0: 	TUint iId;
sl@0: 	TResourceClass iClass;
sl@0: 	TResourceType iType;
sl@0: 	TResourceUsage iUsage;
sl@0: 	TResourceSense iSense;
sl@0: 	TInt iMinLevel;
sl@0: 	TInt iMaxLevel;
sl@0: 	};
sl@0: typedef TPckgBuf<TResourceInfo> TResourceInfoBuf;
sl@0: 
sl@0: 
sl@0: typedef TBuf8<MAX_NAME_LENGTH_IN_RESMAN> TClientName;
sl@0: 
sl@0: struct TClientInfo
sl@0: 	{
sl@0: 	TClientName iName;
sl@0: 	TUint iId;
sl@0: 	};
sl@0: 
sl@0: typedef TPckgBuf<TClientInfo> TClientInfoBuf;
sl@0: 
sl@0: template <class T>
sl@0: class RSimplePointerArray : private RPointerArrayBase
sl@0: 	{
sl@0: 	public:
sl@0: 	inline RSimplePointerArray();
sl@0: 	inline explicit RSimplePointerArray(TInt aGranularity);
sl@0: 
sl@0: 	inline void Close() {RPointerArrayBase::Close();};
sl@0: 	inline TInt Count() const {return RPointerArrayBase::Count();};
sl@0: 	inline T* const& operator[](TInt anIndex) const {return (T* const&)At(anIndex);};
sl@0: 	inline T*& operator[](TInt anIndex) {return (T*&)At(anIndex);};
sl@0: 	inline TInt Append(const T* anEntry) {return RPointerArrayBase::Append(anEntry);};
sl@0: 	inline TInt Insert(const T* anEntry, TInt aPos) {return RPointerArrayBase::Insert(anEntry,aPos);};
sl@0: 	inline void Remove(TInt anIndex){RPointerArrayBase::Remove(anIndex);};
sl@0: 
sl@0: 	inline T** Entries() {return (T**)(RPointerArrayBase::Entries());};
sl@0: 	};
sl@0: 
sl@0: template <class T>
sl@0: inline RSimplePointerArray<T>::RSimplePointerArray()
sl@0: 	: RPointerArrayBase()
sl@0: 	{}
sl@0: 
sl@0: template <class T>
sl@0: inline RSimplePointerArray<T>::RSimplePointerArray(TInt aGranularity)
sl@0:      : RPointerArrayBase(aGranularity)
sl@0:      {}
sl@0: 
sl@0: 
sl@0: #ifdef RESOURCE_MANAGER_SIMULATED_PSL
sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION2
sl@0: 	_LIT(KLddRootName, "resourcecontrollerextendedcore");
sl@0: #elif defined (PRM_ENABLE_EXTENDED_VERSION)
sl@0: 	_LIT(KLddRootName,"resourcecontrollerextended"); // To support testing of the Extended version
sl@0: #else
sl@0: 	_LIT(KLddRootName,"resourcecontroller");		 // To support testing of the basic version
sl@0: #endif
sl@0: #else
sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION2
sl@0: 	_LIT(KLddRootName, "resmanextendedcore");
sl@0: 	_LIT(KLddName, "resmanextendedcore.ldd");
sl@0: #elif defined(PRM_ENABLE_EXTENDED_VERSION)
sl@0: 	_LIT(KLddRootName,"resmanextended");					// To enable operation with both the basic and Extended PDD 
sl@0: 	_LIT(KLddName, "resmanextended.ldd");					// LDD will support the Extended funcitonality
sl@0: #else
sl@0: 	_LIT(KLddRootName,"ResMan");					// To enable operation with both the basic and Extended PDD 
sl@0: 	_LIT(KLddName, "ResMan.ldd");					// LDD will support the Extended funcitonality
sl@0: #endif
sl@0: #endif
sl@0: 
sl@0: class RBusDevResManUs : public RBusLogicalChannel
sl@0: 	{
sl@0: 	enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
sl@0: 
sl@0: 	public:
sl@0:     /**
sl@0:      * Control requests
sl@0:      */
sl@0:     enum TControl
sl@0: 		{
sl@0: 		EInitialise,						/**< Specify resource requirement and register			*/
sl@0:         EGetNoOfResources,					/**< Read the total number of resources					*/
sl@0:         EGetAllResourcesInfo,				/**< Read the info for all resources into a buffer		*/
sl@0:         EGetNoOfClients,					/**< Read the total number of (Rsource Manager) clients	*/
sl@0:         EGetNamesAllClients,				/**< Read the names of all clients into a buffer		*/
sl@0:         EGetNumClientsUsingResource,		/**< Read the number of clients for specified resource  */
sl@0:         EGetInfoOnClientsUsingResource,		/**< Read the info for clients for specified resource	*/
sl@0:         EGetNumResourcesInUseByClient,		/**< Read the number of resources registered by a client*/
sl@0:         EGetInfoOnResourcesInUseByClient,	/**< Read the info for all resources registered by the 
sl@0: 												 named client into a buffer							*/
sl@0:         EGetResourceIdByName,				/**< Read the ID for a named resource					*/
sl@0:         EGetResourceInfo,					/**< Read the info for specified resource to a buffer	*/
sl@0:         ECancelChangeResourceStateRequests,	/**< Cancel all change state requests for a resource	*/
sl@0:         ECancelGetResourceStateRequests,	/**< Cancel all get state requests for a resource		*/
sl@0:         ECancelChangeNotificationRequests,	/**< Cancel all notification requests for a resource	*/
sl@0:         ECancelChangeResourceState,			/**< Cancel a specific change state request				*/
sl@0:         ECancelGetResourceState,			/**< Cancel a specific get state request				*/
sl@0:         ECancelRequestChangeNotification,	/**< Cancel a specific notification request				*/
sl@0: 		EGetResourceControllerVersion,		/**< Read the version of the Resource Controller		*/
sl@0: 		EGetNumDependentsForResource,		/**< Read the number of dependents for a resource		*/
sl@0: 		EGetDependentsIdForResource			/**< Read the dependency information for a resource		*/
sl@0: #ifdef RESOURCE_MANAGER_SIMULATED_PSL
sl@0: 		,
sl@0: 		// Requests to support testing
sl@0: 		EGetNumCandidateAsyncResources,
sl@0: 		EGetCandidateAsyncResourceId,
sl@0: 		EGetNumCandidateSharedResources,
sl@0: 		EGetCandidateSharedResourceId
sl@0: #endif
sl@0: 		};
sl@0: 
sl@0:     /**
sl@0:      * Asynchronous requests
sl@0:      */
sl@0:     enum TRequest
sl@0: 		{
sl@0: 		EChangeResourceState,				/**< Change the state of a resource							*/
sl@0:         EGetResourceState,					/**< Get the state of a resource							*/
sl@0:         ERequestChangeNotification,			/**< Register for resource change notifications				*/
sl@0:         ERequestQualifiedChangeNotification /**< Register for qualified resource change notifications	*/
sl@0: 		};
sl@0: 
sl@0: #ifndef __KERNEL_MODE__
sl@0:     public:
sl@0: 
sl@0: 	inline TInt Open(TDesC8& aClientName);
sl@0: 	inline TInt Initialise(const TUint8 aNumGetStateRes, const TUint8 aNumSetStateRes, const TUint8 aNumListenableRes);
sl@0: 	inline TVersion VersionRequired() const;
sl@0: 
sl@0: 	// Synchronous requests
sl@0: 	inline TInt GetNoOfResources(TUint& aNumResources, const TBool aInfoRead=ETrue);	
sl@0: 	inline TInt GetAllResourcesInfo(RSimplePointerArray<TResourceInfoBuf>* aInfoPtrs, TUint& aNumResources, const TBool aRefresh=EFalse);
sl@0: 	inline TInt GetNoOfClients(TUint& aNumClients,const TBool aIncludeKern,const TBool aInfoRead=ETrue);
sl@0: 	inline TInt GetNamesAllClients(RSimplePointerArray<TClientName>* aInfoPtrs, TUint& aNumClients, const TBool aIncludeKern, const TBool aRefresh=EFalse);
sl@0: 	inline TInt GetNumClientsUsingResource(const TUint aResourceId, TUint& aNumClients, const TBool aIncludeKern,const TBool aInfoRead=ETrue);
sl@0: 	inline TInt GetInfoOnClientsUsingResource(const TUint aResourceId, TUint& aNumClients, RSimplePointerArray<TClientInfoBuf>* aInfoPtrs, const TBool aIncludeKern, const TBool aRefresh=EFalse);
sl@0: 	inline TInt GetNumResourcesInUseByClient(TDesC8& aClientName, TUint &aNumResources,const TBool aInfoRead=ETrue);
sl@0: 	inline TInt GetInfoOnResourcesInUseByClient(TDesC8& aClientName, TUint &aNumResources, RSimplePointerArray<TResourceInfoBuf>* aInfoPtrs, const TBool aRefresh=EFalse);
sl@0: 
sl@0: 	inline TInt GetResourceIdByName(TDesC8& aResourceName, TUint& aResourceId);
sl@0: 	inline TInt GetResourceInfo(const TUint aResourceId, TResourceInfoBuf* aInfo);
sl@0: 	inline TInt GetResourceControllerVersion(TUint& aVer);
sl@0: 	inline TInt GetNumDependentsForResource(const TUint aResourceId, TUint* aNumDependents, const TBool aInfoRead=ETrue);
sl@0: 	inline TInt GetDependentsIdForResource(const TUint aResourceId, TDes8& aResIdArray, TUint* aNumDepResources, const TBool aRefresh=EFalse);
sl@0: 	// Asynchronous requests
sl@0: 	inline void ChangeResourceState(TRequestStatus& aStatus, const TUint aResourceId, const TInt aNewState);
sl@0: 	inline void GetResourceState(TRequestStatus& aStatus, const TUint aResourceId, const TBool aCached, TInt* aState, TInt *aLevelOwnerId);
sl@0: 	inline void RequestNotification(TRequestStatus& aStatus, const TUint aResourceId);
sl@0: 	inline void RequestNotification(TRequestStatus& aStatus, const TUint aResourceId, const TInt aThreshold, const TBool aDirection);
sl@0: 
sl@0: 	// Cancel requests
sl@0: 	inline TInt CancelChangeResourceStateRequests(const TUint aResourceId);
sl@0: 	inline TInt CancelGetResourceStateRequests(const TUint aResourceId);
sl@0: 	inline TInt CancelNotificationRequests(const TUint aResourceId);
sl@0: 	//
sl@0: 	inline TInt CancelChangeResourceState(TRequestStatus& aStatus);
sl@0: 	inline TInt CancelGetResourceState(TRequestStatus& aStatus);
sl@0: 	inline TInt CancelRequestNotification(TRequestStatus& aStatus);
sl@0: 	//
sl@0: 	inline void CancelAsyncOperation(TRequestStatus* aStatus);
sl@0: 
sl@0: #ifdef RESOURCE_MANAGER_SIMULATED_PSL
sl@0: 	// Requests to support testing
sl@0: 	inline	TInt GetNumCandidateAsyncResources(TUint& aNumResources);
sl@0: 	inline	TInt GetCandidateAsyncResourceId(TUint aIndex, TUint& aResourceId);
sl@0: 	inline	TInt GetNumCandidateSharedResources(TUint& aNumResources);
sl@0: 	inline	TInt GetCandidateSharedResourceId(TUint aIndex, TUint& aResourceId);
sl@0: #endif
sl@0: 
sl@0: #endif
sl@0: 	};
sl@0: 
sl@0: 
sl@0: #ifndef __KERNEL_MODE__
sl@0: #include <d32resmanus.inl>
sl@0: #endif
sl@0: 
sl@0: 
sl@0: #endif