mmresourcemgmt/mmresctrl/inc/mmrcservercontroller.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef MMRCSERVERCONTROLLER_H__
       
    17 #define MMRCSERVERCONTROLLER_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <a3f/a3fbase.h>
       
    22 #include "mmrcclientserver.h"
       
    23 
       
    24 class CMMRCServerInfo;
       
    25 class MMMRCServerInfoState;
       
    26 class CMMRCServerSession;
       
    27 class CMMRCServerRuleManager;
       
    28 class CARNNotificationObject;
       
    29 
       
    30 
       
    31 /**
       
    32 Panic category and codes that MMRCServerController raises on the client
       
    33 */
       
    34 _LIT(KMMRCServerControllerPanicCategory, "MMRCServerController");
       
    35 
       
    36 enum TMMRCServerControllerPanicCodes
       
    37 	{
       
    38 	EProcessNextRequestLeft = 1,
       
    39 	EPushPauseContextLeft,
       
    40 	EPushAllocatedResourceContextFailed
       
    41 	};
       
    42 
       
    43 
       
    44 /**
       
    45 @internalComponent
       
    46 
       
    47 This class implements the MMRC Server Controller. 
       
    48 The main purpose of this class is to control the different transactions
       
    49 */	
       
    50 NONSHARABLE_CLASS( CMMRCServerController ): public CBase
       
    51 	{
       
    52 public:
       
    53 	/**
       
    54 	 * Constructs, and returns a pointer to, a new CMMRCServerController object.
       
    55 	 * Leaves on failure.
       
    56 	 * @return CMMRCServerController* A pointer to newly created utlitly object.
       
    57 	 */		
       
    58 	static CMMRCServerController* NewL(); 
       
    59 	
       
    60 	/**
       
    61 	 * Constructs, leaves object on the cleanup stack, and returns a pointer
       
    62 	 * to, a new CMMRCServerController object.
       
    63 	 * Leaves on failure.
       
    64 	 * @return CMMRCServerController* A pointer to newly created utlitly object.
       
    65 	 */	
       
    66 	static CMMRCServerController* NewLC();
       
    67 	
       
    68 	/**
       
    69 	 * Destructor.
       
    70 	 */
       
    71 	~CMMRCServerController();
       
    72 	
       
    73 public:
       
    74 
       
    75 	/**
       
    76 	 * Process the request pointer by a specific session
       
    77 	 * @param CMMRCServerSession& aServerSession
       
    78 	 * @return KerrNone in case of success of the process
       
    79 	 */
       
    80 	TInt EnqueueRequestL(CMMRCServerSession& aServerSession );
       
    81 	
       
    82 	/** 
       
    83 	 * Callback from the adaptation
       
    84 	 * @param MLogicalChain* aOldChain
       
    85 	 * @param MLogicalChain* aNewChain
       
    86 	 * @param TMMRCAdaptationToServerRequestResults aResult
       
    87 	 */
       
    88 	void AdaptationRequestAcknowledgment(CMMRCServerSession& aServerSessionAllocatedResource, TMMRCAdaptationToServerRequestResults aResult, TInt aError);
       
    89 	
       
    90 	/*
       
    91 	 * 
       
    92 	 */
       
    93 	void CloseSessionByContextId(TInt32 aContextId);
       
    94 	
       
    95 	/*
       
    96 	 * 
       
    97 	 */
       
    98 	void ClientAcknowledgment(CMMRCServerSession& aServerSession);
       
    99 	
       
   100 	/*
       
   101 	 * 
       
   102 	 */
       
   103 	void ServerState(TMMRCServerState& aServerState, TUint64& aContextId) const;
       
   104 	
       
   105 	/**
       
   106 	 * 
       
   107 	 * @param CMMRCServerSession& aServerSession
       
   108 	 * @return KerrNone in case of success of the process
       
   109 	 */	
       
   110 	TInt EnqueueRequestForAPRL(CMMRCServerSession& aServerSession );
       
   111 	
       
   112 	/**
       
   113 	 * 
       
   114 	 * @param CMMRCServerSession& aServerSession
       
   115 	 * @return KerrNone in case of success of the process
       
   116 	 */	
       
   117 	TInt RemoveRequestForAPR(CMMRCServerSession& aServerSession );	
       
   118 	
       
   119 	/**
       
   120 	 * 
       
   121 	 * @return KerrNone in case of success of the process
       
   122 	 */	
       
   123 	TInt WillResumePlay();
       
   124 	
       
   125 
       
   126 private:
       
   127 	/**
       
   128 	 * Process the first request with the highest priority from the FIFO queue
       
   129 	 * @return KerrNone in case of success of the process
       
   130 	 */
       
   131 	TInt ProcessNextRequestL();
       
   132 	
       
   133 	/**
       
   134 	 * Send a resource request to the adaptation
       
   135 	 * @param CMMRCServerSession& aServerSession 
       
   136 	 * @return KerrNone in case of success of the process
       
   137 	 */
       
   138 	TInt SendResourceRequest( CMMRCServerSession& aServerSession );
       
   139 	
       
   140 	/** 
       
   141 	 * Send a preemption request to the adaptation
       
   142 	 * @param CMMRCServerSession& aServerSession 
       
   143 	 * @return KerrNone in case of success of the process
       
   144 	 */
       
   145 	TInt SendPreemptionRequest( CMMRCServerSession& aServerSession );
       
   146 	
       
   147 	/**
       
   148 	 * Pop the decision rule on the base of the current in-process request and a new committed request
       
   149 	 * @param TAudioState aAudioStateAllocatedResource
       
   150 	 * @param TAudioState aAudioStateRequiringProcess
       
   151 	 * @return TMMRCRule
       
   152 	 */
       
   153 	TMMRCRule DecisionRule(TAudioState aAudioStateAllocatedResource, TAudioState aAudioStateRequiringProcess);
       
   154 	
       
   155 	/**
       
   156 	 * Pop the action reason on the base of the last committed request and the current one
       
   157 	 * @param TAudioState aAudioStateLastCommitted
       
   158 	 * @param TAudioState aAudioStateRequested
       
   159 	 * @return TReason
       
   160 	 */
       
   161 	TReason ActionReason(TAudioState aAudioStateLastCommitted, TAudioState aAudioStateRequested);
       
   162 	
       
   163 	/**
       
   164 	 * Notify all the paused client that a resource has been unallocated
       
   165 	 */
       
   166 	void NotifyPausedClientsResourceUnallocated();
       
   167 
       
   168 	
       
   169 	/*
       
   170 	 * 
       
   171 	 */
       
   172 	void Panic(TMMRCServerControllerPanicCodes aCode);
       
   173 
       
   174 private:
       
   175 		
       
   176 	/**
       
   177 	 * By default Symbian 2nd phase constructor is private.
       
   178 	 */
       
   179 	CMMRCServerController();
       
   180 	
       
   181 	/**
       
   182 	 * By default Symbian 2nd phase constructor is private.
       
   183 	 */
       
   184 	void ConstructL();
       
   185 
       
   186 private:
       
   187 	//owned
       
   188 	CMMRCServerInfo* iMMRCServerInfo;
       
   189 	CMMRCServerRuleManager* iMMRCServerRuleManager;
       
   190 	CARNNotificationObject* iARNNotificationObject;
       
   191 	};
       
   192 
       
   193 #endif //__MMRCSERVERCONTROLLER_H__