|
1 // Copyright (c) 2004-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef SYMBIAN_DEN_MSGS_H |
|
22 #define SYMBIAN_DEN_MSGS_H |
|
23 |
|
24 #include <elements/cftransportmsg.h> |
|
25 #include <elements/nm_interfaces.h> |
|
26 #include <elements/sd_mintercept.h> |
|
27 |
|
28 |
|
29 #ifdef _DEBUG |
|
30 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
31 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
32 _LIT(KSpecAssert_ElemSvrDenMsgH, "ElemSvrDenMsgH"); |
|
33 #endif |
|
34 |
|
35 namespace Den |
|
36 { |
|
37 |
|
38 /** Messages from Main Thread to Worker Threads (with Resp messages being responses |
|
39 sent back from Worker) |
|
40 */ |
|
41 class TWorkerMsg : public CommsFW::TCFMessage |
|
42 { |
|
43 public: |
|
44 enum |
|
45 { |
|
46 /** Number of messages reserved for ESock internal usage. Currently bigger than the actual |
|
47 number of messages to provide space for more in the future. |
|
48 @see TWorkerMsg::TCode::ELastWorkerMsgCode |
|
49 */ |
|
50 KWorkerMessageCodeReserveSize = 15 |
|
51 }; |
|
52 |
|
53 enum TCode |
|
54 { |
|
55 /** This is the first message sent on a binding by any worker thread. It identifies the basics |
|
56 about the worker |
|
57 */ |
|
58 EWorkerIntroduction = CommsFW::TCFCommsMessage::ECodePrivateFlag, |
|
59 |
|
60 /** This is the second message sent on a binding by a worker. It identifies a standard set of |
|
61 cookies. In the future it's expected that the legacy transport will only be used for the above |
|
62 initial intro message which will carry a boot-strapping cookie and all other cookies will |
|
63 be identified directly to that one |
|
64 */ |
|
65 EWorkerCookies, |
|
66 |
|
67 /** This is sent from the main thread to all workers when a significant configuration event |
|
68 happens, as indicated in the message (eg the boot of modules) |
|
69 */ |
|
70 EConfigurationComplete, |
|
71 |
|
72 /** This requests that the tier mappings are loaded from CommsDat. A worker can send it to the |
|
73 PitBoss and the PitBoss can send it to the tier resolver. In the latter case the tier resolver |
|
74 responds with TWorkerTierMappingsLoaded |
|
75 */ |
|
76 ELoadTierMappings, |
|
77 |
|
78 /** The tier resolver reports through this that the previously requested load of the tier mappings |
|
79 is complete |
|
80 */ |
|
81 ETierMappingsLoaded, |
|
82 |
|
83 /** This is sent from the PitBoss to a worker thread to notify that another worker has |
|
84 died and the receiver is expected to clean up any data structures/states related to that |
|
85 dead worker (if any). |
|
86 The receiver is expected to respond with a ECleanupDeadPeerResp message. |
|
87 @see TWorkerMsg::ECleanupDeadPeerResp |
|
88 */ |
|
89 ECleanupDeadPeer, |
|
90 |
|
91 /** Response from worker to main thread that cleanup after dead peer has been completed. |
|
92 @see TWorkerMsg::ECleanupDeadPeer |
|
93 */ |
|
94 ECleanupDeadPeerResp, |
|
95 |
|
96 /** Notification that a player role management responsibility has ended (eg a Player data |
|
97 flows signals the Player hosting subconnections when it unbinds, which can only happen when |
|
98 all flows have ceased dependency upon the sub-connections |
|
99 @see TWorkerMsg::TPlaneUnboundMsg |
|
100 */ |
|
101 EPlaneUnbound, |
|
102 |
|
103 /** Carries data that did not fit into EWorkerIntroduction |
|
104 */ |
|
105 EWorkerIntroduction2, |
|
106 |
|
107 /** Introduction message from main thread to workers to prompt objects to join their broker in the main thread |
|
108 */ |
|
109 EFactoryContainerIntroduction, |
|
110 |
|
111 /** Introduces a factory container object broker in the main thread to a worker thread |
|
112 */ |
|
113 EBrokerIntroduction, |
|
114 |
|
115 /** Dummy trailer code to give reference point for starting a following sequence of message codes. */ |
|
116 ELastWorkerMsgCode = CommsFW::TCFCommsMessage::ECodePrivateFlag + KWorkerMessageCodeReserveSize |
|
117 }; |
|
118 |
|
119 inline TWorkerMsg(TInt aCode) |
|
120 { |
|
121 Code(aCode); |
|
122 } |
|
123 }; |
|
124 |
|
125 /** |
|
126 class TWorkerIntroductionMsg |
|
127 */ |
|
128 class TWorkerIntroductionMsg : public TWorkerMsg |
|
129 { |
|
130 public: |
|
131 enum {KCode = TWorkerMsg::EWorkerIntroduction};//< Message code |
|
132 enum {KMaxIntroductionInfoSize = sizeof(Messages::TNodeId)}; |
|
133 |
|
134 inline TWorkerIntroductionMsg(const TWorkerThreadPublicInfo& aWorkerInfo) |
|
135 : TWorkerMsg(KCode) |
|
136 { |
|
137 TParams* params=reinterpret_cast<TParams*>(ParamBlock()); |
|
138 params->iWorkerInfo = aWorkerInfo; |
|
139 params->iDebugMsgIntercept = NULL; |
|
140 params->iFailType = RAllocator::ENone; |
|
141 params->iFailRate = 0; |
|
142 params->iIntroductionInfo[0] = 0; //To mark as empty |
|
143 } |
|
144 |
|
145 inline const TWorkerThreadPublicInfo& WorkerInfo() const |
|
146 { |
|
147 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
148 return params->iWorkerInfo; |
|
149 } |
|
150 |
|
151 inline void IntroductionInfo(TDes8& aIntroductionInfo) const |
|
152 { |
|
153 TInt size = aIntroductionInfo.MaxSize() - aIntroductionInfo.Size(); |
|
154 __ASSERT_DEBUG(size <= KMaxIntroductionInfoSize, User::Panic(KSpecAssert_ElemSvrDenMsgH, 1)); |
|
155 const TParams* params=reinterpret_cast<const TParams*>(ParamBlock()); |
|
156 aIntroductionInfo.Copy(¶ms->iIntroductionInfo[0], KMaxIntroductionInfoSize); |
|
157 } |
|
158 |
|
159 inline void SetIntroductionInfo(const TDesC8& aIntroductionInfo) |
|
160 { |
|
161 __ASSERT_DEBUG(aIntroductionInfo.Size() <= KMaxIntroductionInfoSize, User::Panic(KSpecAssert_ElemSvrDenMsgH, 2)); |
|
162 |
|
163 TParams* params=reinterpret_cast<TParams*>(ParamBlock()); |
|
164 __ASSERT_DEBUG(params->iIntroductionInfo[0] == 0, User::Panic(KSpecAssert_ElemSvrDenMsgH, 3)); |
|
165 Mem::Copy(params->iIntroductionInfo, aIntroductionInfo.Ptr(), aIntroductionInfo.Size()); |
|
166 } |
|
167 |
|
168 #ifdef _DEBUG |
|
169 inline void SetFailType(RAllocator::TAllocFail aFailType) |
|
170 { |
|
171 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
172 params->iFailType = aFailType; |
|
173 } |
|
174 inline RAllocator::TAllocFail FailType() const |
|
175 { |
|
176 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
177 return params->iFailType; |
|
178 } |
|
179 inline void SetFailRate(TInt aFailRate) |
|
180 { |
|
181 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
182 params->iFailRate = aFailRate; |
|
183 } |
|
184 inline TInt FailRate() const |
|
185 { |
|
186 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
187 return params->iFailType; |
|
188 } |
|
189 #endif |
|
190 |
|
191 #if defined (__ELEMENTS_MESSAGE_INTERCEPT_ACTIVE) |
|
192 inline void SetMessageInterceptGlobal(CMessageInterceptRegister* aMsgInterceptRegister) |
|
193 { |
|
194 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
195 params->iDebugMsgIntercept = reinterpret_cast<TAny*>(aMsgInterceptRegister); |
|
196 } |
|
197 inline CMessageInterceptRegister* MsgInterceptRegister() const |
|
198 { |
|
199 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
200 return reinterpret_cast<CMessageInterceptRegister*>(params->iDebugMsgIntercept); |
|
201 } |
|
202 #endif // __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE |
|
203 |
|
204 private: |
|
205 struct TParams /** Message parameters */ |
|
206 { |
|
207 TWorkerThreadPublicInfo iWorkerInfo; //< Crucial information about the worker thread/server |
|
208 // Pointer to the process wide singleton created by the main thread |
|
209 TAny* iDebugMsgIntercept; |
|
210 RAllocator::TAllocFail iFailType; |
|
211 TInt iFailRate; |
|
212 TUint8 iIntroductionInfo[KMaxIntroductionInfoSize]; |
|
213 }; |
|
214 __ASSERT_COMPILE(sizeof(TParams) <= CommsFW::KCFMessageParamBlockSize); |
|
215 }; |
|
216 |
|
217 /** |
|
218 class TWorkerConfigurationComplete |
|
219 @see TWorkerMsg::EConfigurationComplete |
|
220 */ |
|
221 class TWorkerConfigurationComplete : public TWorkerMsg |
|
222 { |
|
223 public: |
|
224 enum {KCode = TWorkerMsg::EConfigurationComplete};/**Message code*/ |
|
225 inline TWorkerConfigurationComplete(TConfigurationCompletionType aType) |
|
226 : TWorkerMsg(KCode) |
|
227 { |
|
228 TParams* params=reinterpret_cast<TParams*>(ParamBlock()); |
|
229 params->iType = aType; |
|
230 } |
|
231 inline TConfigurationCompletionType Type() const |
|
232 { |
|
233 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
234 return params->iType; |
|
235 } |
|
236 private: |
|
237 struct TParams /** Message parameters */ |
|
238 { |
|
239 TConfigurationCompletionType iType; |
|
240 }; |
|
241 }; |
|
242 |
|
243 /** |
|
244 class TWorkerCleanupDeadPeerMsg |
|
245 @see TWorkerMsg::ECleanupDeadPeer |
|
246 */ |
|
247 class TWorkerCleanupDeadPeerMsg : public TWorkerMsg |
|
248 { |
|
249 public: |
|
250 enum {KCode = TWorkerMsg::ECleanupDeadPeer};//< Message code |
|
251 inline TWorkerCleanupDeadPeerMsg(CommsFW::TWorkerId aWorkerId) |
|
252 : TWorkerMsg(KCode) |
|
253 { |
|
254 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
255 params->iWorkerId = aWorkerId; |
|
256 } |
|
257 inline CommsFW::TWorkerId WorkerId() const |
|
258 { |
|
259 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
260 return params->iWorkerId; |
|
261 } |
|
262 private: |
|
263 struct TParams /** Message parameters */ |
|
264 { |
|
265 CommsFW::TWorkerId iWorkerId; //< Identifying which dead peer to cleanup |
|
266 }; |
|
267 }; |
|
268 |
|
269 /** |
|
270 class TWorkerCleanupDeadPeerRespMsg |
|
271 @see TWorkerMsg::ECleanupDeadPeerResp |
|
272 */ |
|
273 class TWorkerCleanupDeadPeerRespMsg : public TWorkerMsg |
|
274 { |
|
275 public: |
|
276 enum {KCode = TWorkerMsg::ECleanupDeadPeerResp};//< Message code |
|
277 inline TWorkerCleanupDeadPeerRespMsg(CommsFW::TWorkerId aWorkerId) |
|
278 : TWorkerMsg(KCode) |
|
279 { |
|
280 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
281 params->iWorkerId = aWorkerId; |
|
282 } |
|
283 inline CommsFW::TWorkerId WorkerId() const |
|
284 { |
|
285 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
286 return params->iWorkerId; |
|
287 } |
|
288 private: |
|
289 struct TParams /** Message parameters */ |
|
290 { |
|
291 CommsFW::TWorkerId iWorkerId; //< Identifying which dead peer the cleanup was related to. |
|
292 }; |
|
293 }; |
|
294 |
|
295 class TPlaneUnboundMsg : public TWorkerMsg |
|
296 { |
|
297 public: |
|
298 enum {KCode = TWorkerMsg::EPlaneUnbound};//< Message code |
|
299 inline TPlaneUnboundMsg(TPlayerRole aPlayerRole) |
|
300 : Den::TWorkerMsg(KCode) |
|
301 { |
|
302 TParams* params=reinterpret_cast<TParams*>(ParamBlock()); |
|
303 params->iPlayerRole = aPlayerRole; |
|
304 } |
|
305 |
|
306 inline const TPlayerRole& PlayerRole() const |
|
307 { |
|
308 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
309 return params->iPlayerRole; |
|
310 } |
|
311 private: |
|
312 struct TParams /** Message parameters */ |
|
313 { |
|
314 TPlayerRole iPlayerRole; |
|
315 }; |
|
316 }; |
|
317 |
|
318 /** |
|
319 class TPlayerMsg |
|
320 Messages from a Dealer to a Player in another thread |
|
321 */ |
|
322 class TPlayerMsg : public CommsFW::TCFMessage |
|
323 { |
|
324 public: |
|
325 enum TCode |
|
326 { |
|
327 /** This is the most common message. It is used to forward IPC requests |
|
328 from a Dealer to a Player. */ |
|
329 EForwardRequest = TWorkerMsg::ELastWorkerMsgCode + 1, |
|
330 |
|
331 /** When a session is closed by a client the Dealer will send this message to all Players |
|
332 that might have relations (sub-sessions) to this session. |
|
333 @note The receiver is expected to response with a ESessionCloseResp message. |
|
334 @see TPlayerMsg::ESessionCloseResp |
|
335 */ |
|
336 ESessionClose, |
|
337 |
|
338 /** Notify the Dealer that cleanup related to the ESessionClose message is completed. |
|
339 @see TPlayerMsg::ESessionClose |
|
340 */ |
|
341 ESessionCloseResp, |
|
342 }; |
|
343 |
|
344 inline TPlayerMsg(TInt aCode) |
|
345 { |
|
346 Code(aCode); |
|
347 } |
|
348 }; |
|
349 |
|
350 /** |
|
351 class TPlayerForwardRequestMsg |
|
352 @see TPlayerMsg::EForwardRequest |
|
353 */ |
|
354 class TPlayerForwardRequestMsg : public TPlayerMsg |
|
355 { |
|
356 public: |
|
357 enum {KCode = TPlayerMsg::EForwardRequest};//< Message code |
|
358 inline TPlayerForwardRequestMsg(const RMessage2& aMsg, CWorkerSubSession* aSubSession):TPlayerMsg(KCode) |
|
359 { |
|
360 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
361 params->iMsg.Adopt(static_cast<Den::RSafeMessage&>(const_cast<RMessage2&>(aMsg))); |
|
362 params->iSubSession=aSubSession; |
|
363 } |
|
364 /* Create requests have no meaningful subsession pointer (it gets created through the request) but can need |
|
365 to communicate additional status. This is carried through these magic subsession consts |
|
366 */ |
|
367 inline static CWorkerSubSession* UnusedParam() |
|
368 { |
|
369 return reinterpret_cast<CWorkerSubSession*>(NULL); |
|
370 } |
|
371 inline static CWorkerSubSession* NormalCreationFlag() |
|
372 { |
|
373 return reinterpret_cast<CWorkerSubSession*>(NULL); |
|
374 } |
|
375 inline static CWorkerSubSession* AbnormalCreationFlag() |
|
376 { |
|
377 return reinterpret_cast<CWorkerSubSession*>(-1); |
|
378 } |
|
379 inline const RSafeMessage& SafeMessage() const |
|
380 { |
|
381 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
382 return params->iMsg; |
|
383 } |
|
384 inline CWorkerSubSession* SubSession() const |
|
385 { |
|
386 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
387 return params->iSubSession; |
|
388 } |
|
389 private: |
|
390 struct TParams /** Message parameters */ |
|
391 { |
|
392 /** The IPC message to process. The Player must complete this itself when ready. |
|
393 When sent to a Player the Dealer will have forgotten completely about it and left |
|
394 the responsibility to the Player. |
|
395 */ |
|
396 RSafeMessage iMsg; |
|
397 CWorkerSubSession* iSubSession; |
|
398 }; |
|
399 |
|
400 __ASSERT_COMPILE(sizeof(TParams) <= CommsFW::KCFMessageParamBlockSize); |
|
401 }; |
|
402 |
|
403 /** |
|
404 class TPlayerSessionCloseMsg |
|
405 @see TPlayerMsg::ESessionClose |
|
406 */ |
|
407 class TPlayerSessionCloseMsg : public TPlayerMsg |
|
408 { |
|
409 public: |
|
410 enum {KCode = TPlayerMsg::ESessionClose};//< Message code |
|
411 inline TPlayerSessionCloseMsg(CWorkerSession* aSession):TPlayerMsg(KCode) |
|
412 { |
|
413 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
414 params->iSession=aSession; |
|
415 } |
|
416 |
|
417 inline CWorkerSession* Session() const |
|
418 { |
|
419 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
420 return params->iSession; |
|
421 } |
|
422 private: |
|
423 struct TParams /** Message parameters */ |
|
424 { |
|
425 CWorkerSession* iSession; //< The session that is being closed. |
|
426 }; |
|
427 }; |
|
428 |
|
429 /** |
|
430 class TPlayerSessionCloseRespMsg |
|
431 @see TPlayerMsg::ESessionCloseResp |
|
432 */ |
|
433 class TPlayerSessionCloseRespMsg : public TPlayerMsg |
|
434 { |
|
435 public: |
|
436 enum {KCode = TPlayerMsg::ESessionCloseResp};//< Message code |
|
437 inline TPlayerSessionCloseRespMsg(CommsFW::TWorkerId aPlayerId, CWorkerSession* aSession) |
|
438 : TPlayerMsg(KCode) |
|
439 { |
|
440 TParams* params = reinterpret_cast<TParams*>(ParamBlock()); |
|
441 params->iSession=aSession; |
|
442 params->iPlayerId=aPlayerId; |
|
443 } |
|
444 inline CWorkerSession* Session() const |
|
445 { |
|
446 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
447 return params->iSession; |
|
448 } |
|
449 inline const CommsFW::TWorkerId WorkerId() const |
|
450 { |
|
451 const TParams* params = reinterpret_cast<const TParams*>(ParamBlock()); |
|
452 return params->iPlayerId; |
|
453 } |
|
454 private: |
|
455 struct TParams /** Message parameters */ |
|
456 { |
|
457 CWorkerSession* iSession; //< The session which was closed |
|
458 CommsFW::TWorkerId iPlayerId; //< Id of the sending worker thread |
|
459 }; |
|
460 }; |
|
461 |
|
462 class TWorkerTransportMsg : public CommsFW::TCFMessage |
|
463 { |
|
464 public: |
|
465 inline TWorkerTransportMsg(TInt aCode) |
|
466 { |
|
467 Code(aCode); |
|
468 TWorkerTransportParams* params = reinterpret_cast<TWorkerTransportParams*>(ParamBlock()); |
|
469 params->iStatus = NULL; |
|
470 } |
|
471 inline TWorkerTransportMsg(TInt aCode, TRequestStatus& aStatus) |
|
472 { |
|
473 Code(aCode); |
|
474 TWorkerTransportParams* params = reinterpret_cast<TWorkerTransportParams*>(ParamBlock()); |
|
475 params->iStatus = &aStatus; |
|
476 } |
|
477 inline TRequestStatus& Status() const |
|
478 { |
|
479 const TWorkerTransportParams* params = reinterpret_cast<const TWorkerTransportParams*>(ParamBlock()); |
|
480 return *params->iStatus; |
|
481 } |
|
482 inline TRequestStatus* GetStatusPtr() const |
|
483 { |
|
484 const TWorkerTransportParams* params = reinterpret_cast<const TWorkerTransportParams*>(ParamBlock()); |
|
485 return params->iStatus; |
|
486 } |
|
487 inline void SetStatusPtr(TRequestStatus* aStatus) |
|
488 { |
|
489 TWorkerTransportParams* params = reinterpret_cast<TWorkerTransportParams*>(ParamBlock()); |
|
490 params->iStatus = aStatus; |
|
491 } |
|
492 protected: |
|
493 struct TWorkerTransportParams /** Message parameters */ |
|
494 { |
|
495 TRequestStatus* iStatus; //< Pointer to request status to set when the request is complete. |
|
496 }; |
|
497 }; |
|
498 |
|
499 } //namespace Den |
|
500 |
|
501 #endif |
|
502 //SYMBIAN_DEN_MSGS_H |
|
503 |
|
504 |