|
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 MMRCSERVERINFO_H__ |
|
17 #define MMRCSERVERINFO_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32msgqueue.h> |
|
21 #include "mmrcutil.h" |
|
22 #include "mmrcclientserver.h" |
|
23 #include "mmrcserversession.h" |
|
24 |
|
25 class CMMRCServerController; |
|
26 |
|
27 /** |
|
28 @internalComponent |
|
29 |
|
30 This class implements the MMRC Server Info. |
|
31 The main purpose of this class is to contain the different information |
|
32 about the MMRC Server. |
|
33 The server state |
|
34 The queue of resource Context |
|
35 The queue of resource in process |
|
36 */ |
|
37 NONSHARABLE_CLASS( CMMRCServerInfo ): public CBase |
|
38 { |
|
39 typedef RMMRCFifoQueue<CMMRCServerSession> RMMRCContextsQueueTD; |
|
40 typedef RMMRCFifoOrderQueue<CMMRCServerSession> RMMRCContextsQueueOrderTD; |
|
41 |
|
42 public: |
|
43 /** |
|
44 * Constructs, and returns a pointer to, a new CMMRCServerInfo object. |
|
45 * Leaves on failure. |
|
46 * @param CMMRCServerController& A reference on the MMRC Server controller |
|
47 * @return CMMRCServerInfo* A pointer to newly created utlitly object. |
|
48 */ |
|
49 static CMMRCServerInfo* NewL(CMMRCServerController& aServerController); |
|
50 |
|
51 /** |
|
52 * Constructs, leaves object on the cleanup stack, and returns a pointer |
|
53 * to, a new CMMRCServerInfo object. |
|
54 * Leaves on failure. |
|
55 * @param CMMRCServerController& A reference on the MMRC Server controller |
|
56 * @return CMMRCServerInfo* A pointer to newly created utlitly object. |
|
57 */ |
|
58 static CMMRCServerInfo* NewLC(CMMRCServerController& aServerController); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 ~CMMRCServerInfo(); |
|
64 |
|
65 public: |
|
66 |
|
67 TInt AllocatedPausedContextsCount(); |
|
68 TInt RequestsCount(); |
|
69 TInt AllocatedResourceContextsCount(); |
|
70 TInt AllocatedAPRContextsCount(); |
|
71 |
|
72 |
|
73 /** |
|
74 * Change the state of the server |
|
75 * @param TMMRCServerState aNewState |
|
76 * @param TUint64 aContextId |
|
77 */ |
|
78 void SwitchServerState(TMMRCServerState aNewState, TUint64 aContextId); |
|
79 |
|
80 |
|
81 /** |
|
82 * get the state of the server |
|
83 * @param TMMRCServerState the state of the server |
|
84 * @param TUint64 aContextId |
|
85 */ |
|
86 void ServerState(TMMRCServerState& aServerState, TUint64& aContextId) const; |
|
87 |
|
88 /** |
|
89 * Push a Context on the Context queue |
|
90 * @param CMMRCServerSession& aServerSession |
|
91 * @leave in case of memory error |
|
92 */ |
|
93 void PushRequestL(const CMMRCServerSession& aServerSession); |
|
94 |
|
95 /** |
|
96 * Pop and remove the first Context from the Context queue |
|
97 * @return CMMRCServerSession* the session of the Context |
|
98 */ |
|
99 CMMRCServerSession* PopAndRemoveFirstRequest(); |
|
100 |
|
101 /** |
|
102 * Pop and remove the first Context from the Context queue by contextId |
|
103 * @param const TAudioContextId& aContextId |
|
104 * @return CMMRCServerSession* the session of the Context |
|
105 */ |
|
106 CMMRCServerSession* PopAndRemoveFirstRequestByContextId( const TAudioContextId& aContextId ); |
|
107 |
|
108 /** |
|
109 * Pop and remove the first Context of the highest priority from the Context queue |
|
110 * @param TInt aPriority |
|
111 * @return CMMRCServerSession* the session of the Context |
|
112 */ |
|
113 CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( ); |
|
114 |
|
115 /** |
|
116 * Pop and remove the first Context of the highest priority and more than aPriority |
|
117 * from the Context queue |
|
118 * @param TInt aPriority |
|
119 * @return CMMRCServerSession* the session of the Context |
|
120 */ |
|
121 CMMRCServerSession* PopAndRemoveRequestFirstHighestPriority( TInt aPriority ); |
|
122 |
|
123 /** |
|
124 * Pop the first Context from the Context queue |
|
125 * @return CMMRCServerSession* the session of the Context |
|
126 */ |
|
127 CMMRCServerSession* PopFirstRequest( ) const; |
|
128 |
|
129 /** |
|
130 * Pop the first Context of the highest priority from the Context queue |
|
131 * @return CMMRCServerSession* the session of the Context |
|
132 */ |
|
133 CMMRCServerSession* PopRequestFirstHighestPriority( ) const; |
|
134 |
|
135 /** |
|
136 * Pop the first Context of the highest priority and more than aPriority |
|
137 * from the Context queue |
|
138 * @param TInt aPriority |
|
139 * @return CMMRCServerSession* the session of the Context |
|
140 */ |
|
141 CMMRCServerSession* PopRequestFirstHighestPriority( TInt aPriority ) const; |
|
142 |
|
143 /** |
|
144 * Push an Context on the in-process Context queue |
|
145 * @param CMMRCServerSession& aServerSession |
|
146 * @leave in case of memory error |
|
147 */ |
|
148 void PushAllocatedResourceContextL(const CMMRCServerSession& aServerSession); |
|
149 |
|
150 /** |
|
151 * Pop and remove the first Context of the highest priority from the in-process Context queue |
|
152 * @return CMMRCServerSession* the session of the Context |
|
153 */ |
|
154 CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContext(); |
|
155 |
|
156 /** |
|
157 * Pop and remove the first Context from the in-process Context queue by contextId |
|
158 * @param const TAudioContextId& aContextId |
|
159 * @return CMMRCServerSession* the session of the Context |
|
160 */ |
|
161 CMMRCServerSession* PopAndRemoveFirstAllocatedResourceContextByContextId( const TAudioContextId& aContextId ); |
|
162 |
|
163 |
|
164 /** |
|
165 * Pop the first Context from the in-process Context queue |
|
166 * @return CMMRCServerSession* the session of the Context |
|
167 */ |
|
168 CMMRCServerSession* PopFirstAllocatedResourceContext( ) const; |
|
169 |
|
170 void PushPausedContextL(const CMMRCServerSession& aServerSession ); |
|
171 CMMRCServerSession* PopAndRemoveFirstPausedContext(); |
|
172 CMMRCServerSession* PopAndRemovePausedContext(const TAudioContextId& aContextId ); |
|
173 CMMRCServerSession* PausedContextByIndex(TInt aIndex); |
|
174 |
|
175 void PushAPRContextL(const CMMRCServerSession& aServerSession ); |
|
176 CMMRCServerSession* PopAndRemoveFirstAPRContext(); |
|
177 CMMRCServerSession* PopAndRemoveFirstAPRContextByContextId(const TAudioContextId& aContextId ); |
|
178 CMMRCServerSession* PopFirstAPRContext() const; |
|
179 |
|
180 TBool IsOnAPRList(TAudioContextId aId); |
|
181 TBool IsOnPauseList(TAudioContextId aId); |
|
182 |
|
183 |
|
184 private: |
|
185 /** |
|
186 * Push an Context on the Context queue in parameter |
|
187 * @param RMMRCContextsQueueTD& aContextsQueue |
|
188 * @param CMMRCServerSession& aServerSession |
|
189 * @leave in case of memory error |
|
190 */ |
|
191 void PushContextL(RMMRCContextsQueueTD& aContextsQueue, const CMMRCServerSession& aServerSession); |
|
192 |
|
193 /** |
|
194 * Pop and remove the first Context of the highest priority from the Context queue in parameter |
|
195 * @param RMMRCContextsQueueTD& aContextsQueue |
|
196 * @return CMMRCServerSession* the session of the Context |
|
197 */ |
|
198 CMMRCServerSession* PopAndRemoveFirstContext(RMMRCContextsQueueTD& aContextsQueue); |
|
199 |
|
200 /** |
|
201 * Pop and remove the first Context from the Context queue in parameter by contextId |
|
202 * @param RMMRCContextsQueueTD& aContextsQueue |
|
203 * @param const TAudioContextId& aContextId |
|
204 * @return CMMRCServerSession* the session of the Context |
|
205 */ |
|
206 CMMRCServerSession* PopAndRemoveFirstContextByContextId(RMMRCContextsQueueTD& aContextsQueue, const TAudioContextId& aContextId ); |
|
207 |
|
208 /** |
|
209 * Pop and remove the first Context of the highest priority from the Context queue in parameter |
|
210 * @param RMMRCContextsQueueTD& aContextsQueue |
|
211 * @return CMMRCServerSession* the session of the Context |
|
212 */ |
|
213 CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue); |
|
214 |
|
215 /** |
|
216 * Pop and remove the first Context of the highest priority and more than aPriority |
|
217 * from the Context queue in parameter |
|
218 * @param RMMRCContextsQueueTD& aContextsQueue |
|
219 * @param TInt aPriority |
|
220 * @return CMMRCServerSession* the session of the Context |
|
221 */ |
|
222 CMMRCServerSession* PopAndRemoveContextFirstHighestPriority(RMMRCContextsQueueTD& aContextsQueue, TInt aPriority ); |
|
223 |
|
224 /** |
|
225 * Pop the first Context from the Context queue in parameter |
|
226 * @param RMMRCContextsQueueTD& aContextsQueue |
|
227 * @return CMMRCServerSession* the session of the Context |
|
228 */ |
|
229 CMMRCServerSession* PopFirstContext(const RMMRCContextsQueueTD& aContextsQueue) const; |
|
230 |
|
231 /** |
|
232 * Pop the first Context of the highest priority from the Context queue in parameter |
|
233 * @param RMMRCContextsQueueTD& aContextsQueue |
|
234 * @return CMMRCServerSession* the session of the Context |
|
235 */ |
|
236 CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue) const; |
|
237 |
|
238 /** |
|
239 * Pop the first Context of the highest priority and more than aPriority |
|
240 * from the Context queue in parameter |
|
241 * @param RMMRCContextsQueueTD& aContextsQueue |
|
242 * @param TInt aPriority |
|
243 * @return CMMRCServerSession* the session of the Context |
|
244 */ |
|
245 CMMRCServerSession* PopContextFirstHighestPriority(const RMMRCContextsQueueTD& aContextsQueue, TInt aPriority ) const; |
|
246 |
|
247 void PushContextInOrderL(RMMRCContextsQueueOrderTD& aContextsQueue, const CMMRCServerSession& aServerSession); |
|
248 CMMRCServerSession* PopAndRemoveFirstContextForPause(RMMRCContextsQueueOrderTD& aContextsQueue); |
|
249 CMMRCServerSession* PopAndRemoveContextIdForPause(RMMRCContextsQueueOrderTD& aContextsQueue, const TAudioContextId& aContextId ); |
|
250 CMMRCServerSession* PausedContextByIndexForPause(RMMRCContextsQueueOrderTD& aContextsQueue, TInt aIndex); |
|
251 |
|
252 |
|
253 private: |
|
254 /** |
|
255 * By default Symbian 2nd phase constructor is private. |
|
256 * @param CMMRCServerController& A reference on the MMRC Server controller |
|
257 */ |
|
258 CMMRCServerInfo(CMMRCServerController& aServerController); |
|
259 |
|
260 /** |
|
261 * By default Symbian 2nd phase constructor is private. |
|
262 */ |
|
263 void ConstructL(); |
|
264 |
|
265 private: |
|
266 CMMRCServerController& iMMRCServerController; |
|
267 TMMRCServerState iMMRCServerInfoState; |
|
268 RMMRCContextsQueueTD iMMRCContextsQueue; //0 or more context(s) |
|
269 RMMRCContextsQueueTD iMMRCAllocatedResourceContextsQueue; |
|
270 RMMRCContextsQueueOrderTD iMMRCPausedContextsQueue; |
|
271 RMMRCContextsQueueTD iMMRCAPRContextsQueue; |
|
272 TUint64 iLastTransactionContextId; |
|
273 }; |
|
274 |
|
275 #endif //__MMRCSERVERINFO_H__ |