sl@0: // Copyright (c) 2007-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 "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: // sl@0: sl@0: #ifndef MMRCSERVERINFO_H__ sl@0: #define MMRCSERVERINFO_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include "mmrcutil.h" sl@0: #include "mmrcclientserver.h" sl@0: #include "mmrcserversession.h" sl@0: sl@0: class CMMRCServerController; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: This class implements the MMRC Server Info. sl@0: The main purpose of this class is to contain the different information sl@0: about the MMRC Server. sl@0: The server state sl@0: The queue of resource Context sl@0: The queue of resource in process sl@0: */ sl@0: NONSHARABLE_CLASS( CMMRCServerInfo ): public CBase sl@0: { sl@0: typedef RMMRCFifoQueue RMMRCContextsQueueTD; sl@0: typedef RMMRCFifoOrderQueue RMMRCContextsQueueOrderTD; sl@0: sl@0: public: sl@0: /** sl@0: * Constructs, and returns a pointer to, a new CMMRCServerInfo object. sl@0: * Leaves on failure. sl@0: * @param CMMRCServerController& A reference on the MMRC Server controller sl@0: * @return CMMRCServerInfo* A pointer to newly created utlitly object. sl@0: */ sl@0: static CMMRCServerInfo* NewL(CMMRCServerController& aServerController); sl@0: sl@0: /** sl@0: * Constructs, leaves object on the cleanup stack, and returns a pointer sl@0: * to, a new CMMRCServerInfo object. sl@0: * Leaves on failure. sl@0: * @param CMMRCServerController& A reference on the MMRC Server controller sl@0: * @return CMMRCServerInfo* A pointer to newly created utlitly object. sl@0: */ sl@0: static CMMRCServerInfo* NewLC(CMMRCServerController& aServerController); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~CMMRCServerInfo(); sl@0: sl@0: public: sl@0: sl@0: TInt AllocatedPausedContextsCount(); sl@0: TInt RequestsCount(); sl@0: TInt AllocatedResourceContextsCount(); sl@0: TInt AllocatedAPRContextsCount(); sl@0: sl@0: sl@0: /** sl@0: * Change the state of the server sl@0: * @param TMMRCServerState aNewState sl@0: * @param TUint64 aContextId sl@0: */ sl@0: void SwitchServerState(TMMRCServerState aNewState, TUint64 aContextId); sl@0: sl@0: sl@0: /** sl@0: * get the state of the server sl@0: * @param TMMRCServerState the state of the server sl@0: * @param TUint64 aContextId sl@0: */ sl@0: void ServerState(TMMRCServerState& aServerState, TUint64& aContextId) const; sl@0: sl@0: /** sl@0: * Push a Context on the Context queue sl@0: * @param CMMRCServerSession& aServerSession sl@0: * @leave in case of memory error sl@0: */ sl@0: void PushRequestL(const CMMRCServerSession& aServerSession); sl@0: sl@0: /** sl@0: * Pop and remove the first Context from the Context queue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstRequest(); sl@0: sl@0: /** sl@0: * Pop and remove the first Context from the Context queue by contextId sl@0: * @param const TAudioContextId& aContextId sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstRequestByContextId( const TAudioContextId& aContextId ); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority from the Context queue sl@0: * @param TInt aPriority sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( ); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority and more than aPriority sl@0: * from the Context queue sl@0: * @param TInt aPriority sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( TInt aPriority ); sl@0: sl@0: /** sl@0: * Pop the first Context from the Context queue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopFirstRequest( ) const; sl@0: sl@0: /** sl@0: * Pop the first Context of the highest priority from the Context queue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopRequestFirstHighestPriority( ) const; sl@0: sl@0: /** sl@0: * Pop the first Context of the highest priority and more than aPriority sl@0: * from the Context queue sl@0: * @param TInt aPriority sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopRequestFirstHighestPriority( TInt aPriority ) const; sl@0: sl@0: /** sl@0: * Push an Context on the in-process Context queue sl@0: * @param CMMRCServerSession& aServerSession sl@0: * @leave in case of memory error sl@0: */ sl@0: void PushAllocatedResourceContextL(const CMMRCServerSession& aServerSession); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority from the in-process Context queue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContext(); sl@0: sl@0: /** sl@0: * Pop and remove the first Context from the in-process Context queue by contextId sl@0: * @param const TAudioContextId& aContextId sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContextByContextId( const TAudioContextId& aContextId ); sl@0: sl@0: sl@0: /** sl@0: * Pop the first Context from the in-process Context queue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopFirstAllocatedResourceContext( ) const; sl@0: sl@0: void PushPausedContextL(const CMMRCServerSession& aServerSession ); sl@0: CMMRCServerSession* PopAndRemoveFirstPausedContext(); sl@0: CMMRCServerSession* PopAndRemovePausedContext(const TAudioContextId& aContextId ); sl@0: CMMRCServerSession* PausedContextByIndex(TInt aIndex); sl@0: sl@0: void PushAPRContextL(const CMMRCServerSession& aServerSession ); sl@0: CMMRCServerSession* PopAndRemoveFirstAPRContext(); sl@0: CMMRCServerSession* PopAndRemoveFirstAPRContextByContextId(const TAudioContextId& aContextId ); sl@0: CMMRCServerSession* PopFirstAPRContext() const; sl@0: sl@0: TBool IsOnAPRList(TAudioContextId aId); sl@0: TBool IsOnPauseList(TAudioContextId aId); sl@0: sl@0: sl@0: private: sl@0: /** sl@0: * Push an Context on the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @param CMMRCServerSession& aServerSession sl@0: * @leave in case of memory error sl@0: */ sl@0: void PushContextL(RMMRCContextsQueueTD& aContextsQueue, const CMMRCServerSession& aServerSession); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstContext(RMMRCContextsQueueTD& aContextsQueue); sl@0: sl@0: /** sl@0: * Pop and remove the first Context from the Context queue in parameter by contextId sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @param const TAudioContextId& aContextId sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveFirstContextByContextId(RMMRCContextsQueueTD& aContextsQueue, const TAudioContextId& aContextId ); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue); sl@0: sl@0: /** sl@0: * Pop and remove the first Context of the highest priority and more than aPriority sl@0: * from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @param TInt aPriority sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue, TInt aPriority ); sl@0: sl@0: /** sl@0: * Pop the first Context from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopFirstContext(const RMMRCContextsQueueTD& aContextsQueue) const; sl@0: sl@0: /** sl@0: * Pop the first Context of the highest priority from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue) const; sl@0: sl@0: /** sl@0: * Pop the first Context of the highest priority and more than aPriority sl@0: * from the Context queue in parameter sl@0: * @param RMMRCContextsQueueTD& aContextsQueue sl@0: * @param TInt aPriority sl@0: * @return CMMRCServerSession* the session of the Context sl@0: */ sl@0: CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue, TInt aPriority ) const; sl@0: sl@0: void PushContextInOrderL(RMMRCContextsQueueOrderTD& aContextsQueue, const CMMRCServerSession& aServerSession); sl@0: CMMRCServerSession* PopAndRemoveFirstContextForPause(RMMRCContextsQueueOrderTD& aContextsQueue); sl@0: CMMRCServerSession* PopAndRemoveContextIdForPause(RMMRCContextsQueueOrderTD& aContextsQueue, const TAudioContextId& aContextId ); sl@0: CMMRCServerSession* PausedContextByIndexForPause(RMMRCContextsQueueOrderTD& aContextsQueue, TInt aIndex); sl@0: sl@0: sl@0: private: sl@0: /** sl@0: * By default Symbian 2nd phase constructor is private. sl@0: * @param CMMRCServerController& A reference on the MMRC Server controller sl@0: */ sl@0: CMMRCServerInfo(CMMRCServerController& aServerController); sl@0: sl@0: /** sl@0: * By default Symbian 2nd phase constructor is private. sl@0: */ sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: CMMRCServerController& iMMRCServerController; sl@0: TMMRCServerState iMMRCServerInfoState; sl@0: RMMRCContextsQueueTD iMMRCContextsQueue; //0 or more context(s) sl@0: RMMRCContextsQueueTD iMMRCAllocatedResourceContextsQueue; sl@0: RMMRCContextsQueueOrderTD iMMRCPausedContextsQueue; sl@0: RMMRCContextsQueueTD iMMRCAPRContextsQueue; sl@0: TUint64 iLastTransactionContextId; sl@0: }; sl@0: sl@0: #endif //__MMRCSERVERINFO_H__