|
1 // Copyright (c) 2006-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 // COREPRSTATES.CPP |
|
15 // Core PR States |
|
16 // THIS API IS INTERNAL TO NETWORKING AND IS SUBJECT TO CHANGE AND NOT FOR EXTERNAL USE |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 |
|
26 #include <comms-infras/ss_log.h> |
|
27 #include <ss_glob.h> |
|
28 #include <comms-infras/ss_tiermanager.h> |
|
29 #include <comms-infras/ss_tiermanager_internal.h> |
|
30 #include <comms-infras/ss_subconnprov.h> |
|
31 #include <comms-infras/ss_connprov.h> |
|
32 #include <comms-infras/ss_metaconnprov_internal.h> |
|
33 |
|
34 #include <comms-infras/ss_nodeinterfaces.h> |
|
35 |
|
36 #include "ss_coreprstates.h" |
|
37 #include <comms-infras/ss_corepractivities.h> |
|
38 #include "ss_apiext_messages.h" |
|
39 #include <cs_subconparams.h> |
|
40 |
|
41 #include <comms-infras/ss_protocolparameterset.h> |
|
42 |
|
43 #include <elements/nm_messages_errorrecovery.h> |
|
44 #include <elements/nm_messages_peer.h> |
|
45 #include <elements/nm_messages_child.h> |
|
46 |
|
47 #include "ss_flowrequest.h" |
|
48 |
|
49 #include <comms-infras/ss_nodemessages_dataclient.h> |
|
50 #include <comms-infras/ss_nodemessages_serviceprovider.h> |
|
51 #include <comms-infras/ss_nodemessages_subconn.h> |
|
52 #include <comms-infras/ss_nodemessages_rejoiningprovider.h> |
|
53 #include <comms-infras/ss_nodemessages_internal_esock.h> |
|
54 #include <comms-infras/ss_nodemessages_factory.h> |
|
55 #include <comms-infras/ss_nodemessages_mcpr.h> |
|
56 #include <comms-infras/ss_nodemessages_cpr.h> |
|
57 |
|
58 |
|
59 #ifdef _DEBUG |
|
60 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
61 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
62 _LIT(KSpecAssert_ESockCrStaCPRSC, "ESockCrStaCPRSC"); |
|
63 #endif |
|
64 |
|
65 #if defined __CFLOG_ACTIVE || defined LOG || defined ESOCK_EXTLOG_ACTIVE |
|
66 #define KCoreProviderStatesTag KESockCoreProviderTag |
|
67 _LIT8(KCoreProviderStatesSubTag, "coreprovstate"); |
|
68 #endif |
|
69 |
|
70 using namespace CoreStates; |
|
71 using namespace CoreNetStates; |
|
72 using namespace PRStates; |
|
73 using namespace PRActivities; |
|
74 using namespace CoreActivities; |
|
75 using namespace NetStateMachine; |
|
76 using namespace ESock; |
|
77 using namespace CorePanics; |
|
78 using namespace Elements; |
|
79 using namespace Messages; |
|
80 using namespace MeshMachine; |
|
81 using namespace Factories; |
|
82 |
|
83 //-========================================================= |
|
84 // |
|
85 // Panics |
|
86 // |
|
87 //-========================================================= |
|
88 _LIT (KCorePrPanic,"CorePrPanic"); |
|
89 |
|
90 void CorePrPanic(TInt aCode) |
|
91 { |
|
92 User::Panic(KCorePrPanic, aCode); |
|
93 } |
|
94 |
|
95 |
|
96 //-========================================================= |
|
97 // |
|
98 //Utility functions |
|
99 // |
|
100 //-========================================================= |
|
101 //[RZ TODO] This method is a real pain. This method must go. |
|
102 //This method method must be replaced with examining activity->Error() |
|
103 //or similar. |
|
104 TInt ExtractErrorCode(Messages::TSignatureBase& aMessage, MeshMachine::CNodeActivityBase* aActivity = NULL) |
|
105 { |
|
106 if (aActivity && aActivity->Error() != KErrNone) |
|
107 { |
|
108 TInt error = aActivity->Error(); |
|
109 aActivity->SetError(KErrNone); |
|
110 return error; |
|
111 } |
|
112 |
|
113 TInt code = KErrCancel; |
|
114 |
|
115 if ( (aMessage.IsMessage<TCFServiceProvider::TStopped>()) || |
|
116 (aMessage.IsMessage<TCFServiceProvider::TStop>()) || |
|
117 (aMessage.IsMessage<TCFDataClient::TStopped>()) || |
|
118 (aMessage.IsMessage<TCFDataClient::TStop>()) ) |
|
119 { |
|
120 code = static_cast<const Messages::TSigNumber&>(aMessage).iValue; |
|
121 } |
|
122 else if ( (aMessage.IsMessage<TCFControlClient::TGoneDown>()) || |
|
123 (aMessage.IsMessage<TCFControlProvider::TDataClientGoneDown>()) ) |
|
124 { |
|
125 code = static_cast<const Messages::TSigNumberNumber&>(aMessage).iValue1; |
|
126 } |
|
127 else if ( aMessage.IsMessage<TEErrorRecovery::TErrorRecoveryResponse>() ) |
|
128 { |
|
129 //Action must be propagate or there is no error code (your activity flow is faulty)! |
|
130 const Messages::TSigErrResponse& sig = static_cast<const Messages::TSigErrResponse&>(aMessage); |
|
131 __ASSERT_DEBUG(sig.iErrResponse.iAction==Messages::TErrResponse::EPropagate, User::Panic(KSpecAssert_ESockCrStaCPRSC, 1)); |
|
132 code = sig.iErrResponse.iError; |
|
133 } |
|
134 return code; |
|
135 } |
|
136 |
|
137 |
|
138 //-========================================================= |
|
139 // |
|
140 //Common States and Transitions |
|
141 // |
|
142 //-========================================================= |
|
143 |
|
144 EXPORT_C TBool ASetErrorState::Accept(TNodeContextBase& aContext, TBool aSuperAccept) |
|
145 { |
|
146 TEBase::TError* msg = message_cast<TEBase::TError>(&aContext.iMessage); |
|
147 if (msg && aSuperAccept == EFalse && aContext.iNodeActivity != NULL) |
|
148 { |
|
149 aContext.iNodeActivity->SetError(msg->iValue); |
|
150 msg->ClearMessageId(); |
|
151 return EFalse; |
|
152 } |
|
153 return aSuperAccept; |
|
154 } |
|
155 |
|
156 EXPORT_C TInt ACancelOrErrorOrTag::TransitionTag(TNodeContextBase& aContext, TInt aTag) |
|
157 { |
|
158 if(aContext.iMessage.IsMessage<TEBase::TCancel>()) |
|
159 { |
|
160 return MeshMachine::KCancelTag; |
|
161 } |
|
162 if(aContext.iMessage.IsMessage<TEBase::TError>()) |
|
163 { |
|
164 return MeshMachine::KErrorTag; |
|
165 } |
|
166 return aTag; |
|
167 } |
|
168 |
|
169 EXPORT_DEFINE_SMELEMENT(TForwardToControlProvider, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
170 EXPORT_C void TForwardToControlProvider::DoL() |
|
171 { |
|
172 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), |
|
173 iContext.iMessage, TClientType(TCFClientType::ECtrlProvider)); |
|
174 } |
|
175 |
|
176 EXPORT_DEFINE_SMELEMENT(TForwardToControlClients, NetStateMachine::MStateTransition, PRStates::TContext) |
|
177 void TForwardToControlClients::DoL() |
|
178 { |
|
179 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), iContext.iMessage, TClientType(TCFClientType::ECtrl)); |
|
180 } |
|
181 |
|
182 EXPORT_DEFINE_SMELEMENT(TPanic, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
183 EXPORT_C void TPanic::DoL() |
|
184 { |
|
185 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockCrStaCPRSC, 2)); |
|
186 } |
|
187 |
|
188 EXPORT_DEFINE_SMELEMENT(TPostToOriginators, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
189 EXPORT_C void TPostToOriginators::DoL() |
|
190 { |
|
191 iContext.iNodeActivity->PostToOriginators(iContext.iMessage); |
|
192 } |
|
193 |
|
194 EXPORT_DEFINE_SMELEMENT(TAddAuxClient, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
195 EXPORT_C void TAddAuxClient::DoL() |
|
196 { |
|
197 //TODO - what is this hack about? Please raise a defect. |
|
198 iContext.Node().AddClientL(TNodeId::NullId(), TClientType(TCFClientType::EAux)); |
|
199 } |
|
200 |
|
201 EXPORT_DEFINE_SMELEMENT(TRemoveAuxClient, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
202 EXPORT_C void TRemoveAuxClient::DoL() |
|
203 { |
|
204 TNodeSignal::TMessageId noPeerIds[] = { |
|
205 TNodeSignal::TMessageId() |
|
206 }; |
|
207 TEChild::TLeft leaveMsg; |
|
208 |
|
209 //DEF117712: Reentering mesh engine from TRemoveAuxClient::DoL has been raised on this. |
|
210 //Must be removed or explained (as an exception - why safe here?), as re-entering the MM engine is forbidden. |
|
211 CoreNetStates::TContext ctx(iContext.Node(), leaveMsg, iContext.iSender, iContext.iRecipient); |
|
212 iContext.Node().Received(noPeerIds, ctx); |
|
213 } |
|
214 |
|
215 //-========================================================= |
|
216 // |
|
217 //Control Client Join |
|
218 // |
|
219 //-========================================================= |
|
220 |
|
221 EXPORT_DEFINE_SMELEMENT(TAddControlClientAndSendJoinCompleteIfRequest, NetStateMachine::MStateTransition, PRStates::TContext) |
|
222 EXPORT_C void TAddControlClientAndSendJoinCompleteIfRequest::DoL() |
|
223 { |
|
224 //Make sure the client is in the client's table (add if not already there). |
|
225 if (iContext.iMessage.IsMessage<TCFPeer::TJoinRequest>()) |
|
226 { |
|
227 TCFPeer::TJoinRequest& msg = message_cast<TCFPeer::TJoinRequest>(iContext.iMessage); |
|
228 |
|
229 // Client type could be Messages::TClientType::EWorker (Selection Request) |
|
230 // or ESock::TCFClientType::ECtrl, possibly others but not ESock::TCFClientType::EData |
|
231 // which is handled by another activity |
|
232 __ASSERT_DEBUG(msg.iClientType.Type() != (TUint32)TCFClientType::EData, User::Panic(KSpecAssert_ESockCrStaCPRSC, 3)); |
|
233 |
|
234 // iContext.Node().AddClientL(msg.iNodeId, TClientType(TCFClientType::ECtrl,msg.iValue)); |
|
235 iContext.Node().AddClientL(msg.iNodeId, TClientType(TCFClientType::ECtrl)); |
|
236 //Send confirmation |
|
237 RClientInterface::OpenPostMessageClose(iContext.NodeId(), iContext.iSender, TCFPeer::TJoinComplete().CRef()); |
|
238 } |
|
239 else |
|
240 { |
|
241 TCFFactory::TPeerFoundOrCreated& msg = message_cast<TCFFactory::TPeerFoundOrCreated>(iContext.iMessage); |
|
242 iContext.Node().AddClientL(address_cast<TNodeId>(iContext.iSender), TClientType(TCFClientType::ECtrl, msg.iValue)); |
|
243 } |
|
244 |
|
245 //[399TODO] RZ: this call is safe as it checks for the existence of the ControlProvider |
|
246 //same as TSendDataClientIdle. Though it looks a bit not elegant, cos' either this has |
|
247 //to be a separate transition (why check ControlProvider then?) or it can always be |
|
248 //aggregated with join/leave - why separate export then? |
|
249 TSendDataClientActive dcActive(iContext); |
|
250 dcActive.DoL(); |
|
251 } |
|
252 |
|
253 |
|
254 EXPORT_DEFINE_SMELEMENT(TAwaitingApplyResponse, NetStateMachine::MState, CoreStates::TContext) |
|
255 EXPORT_C TBool TAwaitingApplyResponse::Accept() |
|
256 { |
|
257 return (iContext.iMessage.IsMessage<TCFScpr::TApplyResponse>()); |
|
258 } |
|
259 |
|
260 EXPORT_DEFINE_SMELEMENT(TSendApplyRequest, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
261 EXPORT_C void TSendApplyRequest::DoL() |
|
262 { |
|
263 __ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 4)); |
|
264 if (iContext.Node().ServiceProvider() == NULL) |
|
265 { |
|
266 User::Leave(KErrNotReady); |
|
267 } |
|
268 iContext.iNodeActivity->PostRequestTo(*iContext.Node().ServiceProvider(), |
|
269 TCFScpr::TApplyRequest().CRef()); |
|
270 } |
|
271 |
|
272 //-========================================================= |
|
273 // |
|
274 //Data Client Join |
|
275 // |
|
276 //-========================================================= |
|
277 |
|
278 EXPORT_DEFINE_SMELEMENT(TAddDataClient, NetStateMachine::MStateTransition, PRStates::TContext) |
|
279 EXPORT_C void TAddDataClient::DoL() |
|
280 { |
|
281 Messages::TNodeId* client = NULL; |
|
282 TCFClientType::TFlags clientFlags = (TCFClientType::TFlags)0; |
|
283 TCFFactory::TPeerFoundOrCreated* dataClientJoinedMsg = message_cast<TCFFactory::TPeerFoundOrCreated>(&iContext.iMessage); |
|
284 |
|
285 if ( dataClientJoinedMsg ) |
|
286 { |
|
287 // Message "TJoined" => data client already joined (normally when "freshly" created) |
|
288 client = &dataClientJoinedMsg->iNodeId; |
|
289 clientFlags = (TCFClientType::TFlags)(dataClientJoinedMsg->iValue); |
|
290 } |
|
291 else |
|
292 { |
|
293 // Message "TJoinRequest" => data client requesting to join (when moved from one owner to another). |
|
294 TCFPeer::TJoinRequest& dataClientJoinReqMsg = |
|
295 message_cast<TCFPeer::TJoinRequest>(iContext.iMessage); |
|
296 client = &dataClientJoinReqMsg.iNodeId; |
|
297 clientFlags = static_cast<TCFClientType::TFlags>(dataClientJoinReqMsg.iClientType.Flags()); |
|
298 //[EC120TODO]: RZ When ib earth does the sender of TJoinRequest specifies a different type than |
|
299 // EData. API classification will clear this up though scrapping explicit Contrl/Data join msgs. |
|
300 // So each join message will indeed carry a type. |
|
301 __ASSERT_DEBUG(dataClientJoinReqMsg.iClientType.Type() == TCFClientType::EData, User::Panic(KSpecAssert_ESockCrStaCPRSC, 5)); |
|
302 } |
|
303 |
|
304 __ASSERT_DEBUG(client, User::Panic(KSpecAssert_ESockCrStaCPRSC, 6)); |
|
305 __ASSERT_DEBUG(!client->IsNull(), User::Panic(KSpecAssert_ESockCrStaCPRSC, 7)); //Don't run this transition when you have received no data client from the factory! |
|
306 iContext.iPeer = iContext.Node().AddClientL(*client, TClientType(TCFClientType::EData, clientFlags)); |
|
307 } |
|
308 |
|
309 EXPORT_C void TAddDataClient::Error(TInt aError) |
|
310 { |
|
311 TCFFactory::TPeerFoundOrCreated* joinMsg = message_cast<TCFFactory::TPeerFoundOrCreated>(&iContext.iMessage); |
|
312 if (joinMsg) |
|
313 { |
|
314 RClientInterface::OpenPostMessageClose(iContext.NodeId(), joinMsg->iNodeId, |
|
315 TEChild::TDestroy().CRef()); |
|
316 |
|
317 if (iContext.iPeer) |
|
318 { |
|
319 iContext.Node().RemoveClient(iContext.iPeer->RecipientId()); |
|
320 } |
|
321 } |
|
322 TStateTransition<TContext>::Error(aError); |
|
323 } |
|
324 |
|
325 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientJoinRequest, NetStateMachine::MState, CoreNetStates::TContext) |
|
326 EXPORT_C TBool CoreNetStates::TAwaitingDataClientJoinRequest::Accept() |
|
327 { |
|
328 TCFPeer::TJoinRequest* msg = message_cast<TCFPeer::TJoinRequest>(&iContext.iMessage); |
|
329 if (msg != NULL) |
|
330 { |
|
331 if (msg->iClientType.Type() & TCFClientType::EData) |
|
332 return ETrue; |
|
333 } |
|
334 return EFalse; |
|
335 } |
|
336 |
|
337 EXPORT_DEFINE_SMELEMENT(TAddDataClientAndRespond, NetStateMachine::MStateTransition, PRStates::TContext) |
|
338 EXPORT_C void TAddDataClientAndRespond::DoL() |
|
339 { |
|
340 TAddDataClient::DoL(); |
|
341 RClientInterface::OpenPostMessageClose(iContext.NodeId(), iContext.iSender, |
|
342 TCFPeer::TJoinComplete().CRef()); |
|
343 } |
|
344 |
|
345 //-========================================================= |
|
346 // |
|
347 //Data Client Rejoin |
|
348 // |
|
349 //-========================================================= |
|
350 |
|
351 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientRejoin, NetStateMachine::MState, PRStates::TContext) |
|
352 EXPORT_C TBool TAwaitingDataClientRejoin::Accept() |
|
353 { |
|
354 return iContext.iMessage.IsMessage<TCFRejoiningProvider::TRejoinDataClientRequest>(); |
|
355 } |
|
356 |
|
357 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientRejoinOrApplyOrCancel, NetStateMachine::MState, PRStates::TContext) |
|
358 EXPORT_C TBool TAwaitingDataClientRejoinOrApplyOrCancel::Accept() |
|
359 { |
|
360 if (iContext.iMessage.IsMessage<TCFRejoiningProvider::TRejoinDataClientRequest>() || |
|
361 iContext.iMessage.IsMessage<TCFScpr::TApplyRequest>()) |
|
362 { |
|
363 return ETrue; |
|
364 } |
|
365 else if (iContext.iMessage.IsMessage<TEBase::TCancel>()) |
|
366 { |
|
367 __ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 8)); |
|
368 iContext.iNodeActivity->SetIdle(); |
|
369 } |
|
370 return EFalse; |
|
371 } |
|
372 |
|
373 |
|
374 EXPORT_DEFINE_SMELEMENT(TAwaitingRejoinDataClientComplete, NetStateMachine::MState, PRStates::TContext) |
|
375 EXPORT_C TBool TAwaitingRejoinDataClientComplete::Accept() |
|
376 { |
|
377 return iContext.iMessage.IsMessage<TCFRejoiningProvider::TRejoinComplete>(); |
|
378 } |
|
379 |
|
380 EXPORT_DEFINE_SMELEMENT(TSendRejoinComplete, NetStateMachine::MStateTransition, PRStates::TContext) |
|
381 EXPORT_C void TSendRejoinComplete::DoL() |
|
382 { |
|
383 __ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 9)); |
|
384 iContext.iNodeActivity->PostToOriginators(TCFRejoiningProvider::TRejoinComplete().CRef()); |
|
385 } |
|
386 |
|
387 |
|
388 //-========================================================= |
|
389 // |
|
390 //Client Leave && Client Leave Request |
|
391 // |
|
392 //-========================================================= |
|
393 |
|
394 EXPORT_DEFINE_SMELEMENT(TAwaitingClientLeave, NetStateMachine::MState, CoreStates::TContext) |
|
395 EXPORT_C TBool TAwaitingClientLeave::Accept() |
|
396 { |
|
397 return iContext.iMessage.IsMessage<TEChild::TLeft>() |
|
398 || iContext.iMessage.IsMessage<TEPeer::TLeaveRequest>(); |
|
399 } |
|
400 |
|
401 EXPORT_DEFINE_SMELEMENT(TDestroyOrphanedDataClients, NetStateMachine::MStateTransition, PRStates::TContext) |
|
402 EXPORT_C void TDestroyOrphanedDataClients::DoL() |
|
403 { |
|
404 iContext.Node().DestroyOrphanedDataClients(); |
|
405 } |
|
406 |
|
407 EXPORT_DEFINE_SMELEMENT(TSendDataClientIdle, NetStateMachine::MStateTransition, PRStates::TContext) |
|
408 EXPORT_C void TSendDataClientIdle::DoL() |
|
409 { |
|
410 RNodeInterface* cp = iContext.Node().ControlProvider(); |
|
411 if (cp) |
|
412 { //If there is no Control Provider we probably are an MCPR/Tier Manager/etc |
|
413 cp->PostMessage(iContext.NodeId(), TCFControlProvider::TIdle().CRef()); |
|
414 } |
|
415 } |
|
416 |
|
417 EXPORT_DEFINE_SMELEMENT(TSendDataClientActive, NetStateMachine::MStateTransition, PRStates::TContext) |
|
418 EXPORT_C void TSendDataClientActive::DoL() |
|
419 { |
|
420 RNodeInterface* cp = iContext.Node().ControlProvider(); |
|
421 if (cp) |
|
422 { //If there is no Control Provider we probably are an MCPR/Tier Manager/etc |
|
423 cp->PostMessage(iContext.NodeId(), TCFControlProvider::TActive().CRef()); |
|
424 } |
|
425 } |
|
426 |
|
427 |
|
428 EXPORT_DEFINE_SMELEMENT(TSendDataClientIdleIfNoClients, NetStateMachine::MStateTransition, PRStates::TContext) |
|
429 EXPORT_C void TSendDataClientIdleIfNoClients::DoL() |
|
430 { |
|
431 //A node is idle if it has no EData, ECtrl nor EAux clients. |
|
432 //If a node is idle it should send TDataClientIdle to its Control Provider, |
|
433 //which (in a typical scenario) decides to send TDestroy as a response. |
|
434 //We should process TDestroy by sending TClientLeaving back and destroying self. |
|
435 //Should we be the last client of our Control Provider, the Control Provider |
|
436 //sends TDataClientIdle to its Control Provider triggering a similar cycle. |
|
437 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl|TCFClientType::EAux))==NULL |
|
438 && iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EActive)) == NULL) |
|
439 { |
|
440 TSendDataClientIdle::DoL(); |
|
441 return; |
|
442 } |
|
443 |
|
444 //In the somewhat similar scenario, if the node loses its last control client |
|
445 //and discovers it still has dataclients that are not bound to and are not |
|
446 //started, it will assume the dataclients are idle (unbound and not started |
|
447 //dataclients will never admit to being idle themselves). |
|
448 RNodeInterface* cc = iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl)); |
|
449 if (cc==NULL) |
|
450 { |
|
451 TClientIter<TDefaultClientMatchPolicy> dciter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData), |
|
452 TClientType(0, TCFClientType::EActive|TCFClientType::EActivating|TCFClientType::EStarted|TCFClientType::EStarting|TCFClientType::ELeaving)); |
|
453 |
|
454 TInt i = 0; |
|
455 RNodeInterface* dc; |
|
456 while ((dc = dciter[i++]) != NULL) |
|
457 { |
|
458 RClientInterface::OpenPostMessageClose(dc->RecipientId(), iContext.iNode.Id(), |
|
459 TCFControlProvider::TIdle().CRef()); |
|
460 } |
|
461 } |
|
462 } |
|
463 |
|
464 EXPORT_DEFINE_SMELEMENT(TSendLeaveCompleteIfRequest, NetStateMachine::MStateTransition, PRStates::TContext) |
|
465 EXPORT_C void TSendLeaveCompleteIfRequest::DoL() |
|
466 { |
|
467 if (iContext.iMessage.IsMessage<TEPeer::TLeaveRequest>()) |
|
468 { |
|
469 iContext.PostToSender(TEPeer::TLeaveComplete().CRef()); |
|
470 } |
|
471 } |
|
472 |
|
473 |
|
474 //-========================================================= |
|
475 // |
|
476 //Data Client Idle |
|
477 // |
|
478 //-========================================================= |
|
479 |
|
480 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientIdle, MState, PRStates::TContext) |
|
481 EXPORT_C TBool TAwaitingDataClientIdle::Accept() |
|
482 { |
|
483 if (! iContext.iMessage.IsMessage<TCFControlProvider::TIdle>()) |
|
484 { |
|
485 return EFalse; |
|
486 } |
|
487 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 11)); //TDataClientIdle is a peer message |
|
488 iContext.iPeer->ClearFlags(TCFClientType::EActive); |
|
489 return ETrue; |
|
490 } |
|
491 |
|
492 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientActive, MState, PRStates::TContext) |
|
493 EXPORT_C TBool TAwaitingDataClientActive::Accept() |
|
494 { |
|
495 if (! iContext.iMessage.IsMessage<TCFControlProvider::TActive>()) |
|
496 { |
|
497 return EFalse; |
|
498 } |
|
499 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 12)); //TDataClientActive is a peer message |
|
500 iContext.iPeer->SetFlags(TCFClientType::EActive); |
|
501 return ETrue; |
|
502 } |
|
503 |
|
504 EXPORT_DEFINE_SMELEMENT(THandleDataClientIdle, MStateTransition, PRStates::TContext) |
|
505 EXPORT_C void THandleDataClientIdle::DoL() |
|
506 { |
|
507 // Send Destroy to the node which has sent data client idle, but only if the node |
|
508 // is not in use, i.e. not started/starting/activating and it has not already |
|
509 // been sent destroy. |
|
510 |
|
511 //This will result in a data client leaving which in turn will trigger sending |
|
512 //of TDataClientIdle to the Control Provider if there is no more clients joined to this node. |
|
513 |
|
514 //Activity id does not matter for TDestroy message since there is no response to it. |
|
515 //The only action that may result from sending destroy is reception of a "no peer" |
|
516 //data clent leaving message which is always going to be delivered to the client leaving |
|
517 //activity. |
|
518 //Please do not ASSERT(iContext.iNodeActivity) here! |
|
519 |
|
520 //This transition may only be triggered by a peer message from a data client |
|
521 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 13)); |
|
522 __ASSERT_DEBUG(iContext.iPeer->Type()==TCFClientType::EData, User::Panic(KSpecAssert_ESockCrStaCPRSC, 14)); |
|
523 |
|
524 if (!(iContext.iPeer->Flags() & |
|
525 (TCFClientType::EActivating|TCFClientType::EStarting|TCFClientType::ELeaving|TCFClientType::EStarted))) |
|
526 { |
|
527 // if dataclient is default and there is a non default present, don't kill the default. |
|
528 if (!( iContext.iPeer->Flags() & TCFClientType::EDefault && |
|
529 iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData), |
|
530 TClientType(0, TCFClientType::EDefault)) > 0)) |
|
531 { |
|
532 iContext.iPeer->PostMessage(iContext.NodeId(), TEChild::TDestroy().CRef()); |
|
533 iContext.iPeer->SetFlags(TClientType::ELeaving); |
|
534 } |
|
535 else |
|
536 { |
|
537 __CFLOG_VAR((KCoreProviderStatesTag, KCoreProviderStatesSubTag, _L8("TSendDestroyToSendingDataClient::DoL - default client not destroyed, there is an active non default one"))); |
|
538 } |
|
539 } |
|
540 else |
|
541 { |
|
542 __CFLOG_VAR((KCoreProviderStatesTag, KCoreProviderStatesSubTag, _L8("TSendDestroyToSendingDataClient::DoL - client not destroyed, because it is started or has been requested again"))); |
|
543 TSendDataClientIdleIfNoClients(iContext).DoL(); |
|
544 } |
|
545 } |
|
546 |
|
547 EXPORT_DEFINE_SMELEMENT(TSendGoneDown, NetStateMachine::MStateTransition, PRStates::TContext) |
|
548 EXPORT_C void TSendGoneDown::DoL() |
|
549 { |
|
550 if ( !(iContext.iMessage.IsMessage<TCFServiceProvider::TStopped>()) |
|
551 && !(iContext.iMessage.IsMessage<TCFServiceProvider::TStop>()) |
|
552 && !(iContext.iMessage.IsMessage<TCFDataClient::TStopped>()) |
|
553 && !(iContext.iMessage.IsMessage<TCFDataClient::TStop>()) |
|
554 && !(iContext.iMessage.IsMessage<TCFControlClient::TGoneDown>()) |
|
555 && !(iContext.iMessage.IsMessage<TCFControlProvider::TDataClientGoneDown>()) |
|
556 && !(iContext.iMessage.IsMessage<TEErrorRecovery::TErrorRecoveryResponse>()) ) |
|
557 { |
|
558 CorePrPanic(KPanicIncorrectMessage); |
|
559 } |
|
560 |
|
561 iStopCode = ExtractErrorCode(iContext.iMessage); |
|
562 const TProviderInfo& providerInfo = static_cast<const TProviderInfoExt&>(iContext.Node().AccessPointConfig().FindExtensionL( |
|
563 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))).iProviderInfo; |
|
564 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), TCFControlClient::TGoneDown(iStopCode, providerInfo.APId()).CRef(), TClientType(TCFClientType::ECtrl)); |
|
565 |
|
566 // Tell control provider that we have stopped.. for Tier Notification |
|
567 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), TCFControlProvider::TDataClientStatusChange(TCFControlProvider::TDataClientStatusChange::EStopped).CRef(), TClientType(TCFClientType::ECtrlProvider)); |
|
568 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), TCFControlProvider::TDataClientGoneDown(iStopCode).CRef(), TClientType(TCFClientType::ECtrlProvider)); |
|
569 } |
|
570 |
|
571 |
|
572 //-========================================================= |
|
573 // |
|
574 //Stop |
|
575 // |
|
576 //-========================================================= |
|
577 |
|
578 EXPORT_DEFINE_SMELEMENT(TSendDataClientStopped, NetStateMachine::MStateTransition, PRStates::TContext) |
|
579 EXPORT_C void TSendDataClientStopped::DoL() |
|
580 { |
|
581 // Extract stop code according to the message type that initiated the sending of TCFDataClient::TStopped. |
|
582 // Default to KErrCancel. |
|
583 iStopCode = ExtractErrorCode(iContext.iMessage, iContext.iNodeActivity); |
|
584 |
|
585 TCFDataClient::TStopped dataClientStoppedMessage(iStopCode); |
|
586 if (iContext.iNodeActivity) |
|
587 { |
|
588 iContext.iNodeActivity->PostToOriginators(dataClientStoppedMessage); |
|
589 } |
|
590 else |
|
591 { |
|
592 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 15)); |
|
593 iContext.iPeer->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), dataClientStoppedMessage); |
|
594 } |
|
595 |
|
596 // Tell control provider that we have stopped.. for Tier Notification |
|
597 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
598 TCFControlProvider::TDataClientStatusChange(TCFControlProvider::TDataClientStatusChange::EStopped).CRef(), TClientType(TCFClientType::ECtrlProvider)); |
|
599 |
|
600 TInt numStartActivities = iContext.Node().CountActivities(ECFActivityStart); |
|
601 TInt numStopActivities = iContext.Node().CountActivities(ECFActivityStop); |
|
602 |
|
603 if (numStartActivities == 0 && |
|
604 numStopActivities == 0 && |
|
605 (iContext.iNodeActivity == NULL || iContext.iNodeActivity->FindOriginator(iContext.NodeId()) == KErrNotFound)) |
|
606 { |
|
607 //Send TGoneDown to every control client unless the originator is the local node, |
|
608 //in which case the originator will be responsible for sending TGoneDowns. |
|
609 |
|
610 const TProviderInfo& providerInfo = static_cast<const TProviderInfoExt&>(iContext.Node().AccessPointConfig().FindExtensionL( |
|
611 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))).iProviderInfo; |
|
612 |
|
613 TCFControlClient::TGoneDown goneDown(iStopCode, providerInfo.APId()); |
|
614 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
615 goneDown, TClientType(TCFClientType::ECtrl)); |
|
616 } |
|
617 |
|
618 if (iContext.iNodeActivity) |
|
619 { |
|
620 iContext.iNodeActivity->SetError(KErrNone); |
|
621 } |
|
622 } |
|
623 |
|
624 EXPORT_DEFINE_SMELEMENT(TStopDataClients, NetStateMachine::MStateTransition, PRStates::TContext) |
|
625 EXPORT_C void TStopDataClients::DoL() |
|
626 { |
|
627 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
628 TInt stopCode = ExtractErrorCode(iContext.iMessage); |
|
629 |
|
630 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
631 TCFDataClient::TStop(stopCode).CRef(), TClientType(TCFClientType::EData, TCFClientType::EStarted)); |
|
632 iContext.iNodeActivity->ClearPostedTo(); |
|
633 } |
|
634 |
|
635 EXPORT_DEFINE_SMELEMENT(TStopSelf, NetStateMachine::MStateTransition, PRStates::TContext) |
|
636 EXPORT_C void TStopSelf::DoL() |
|
637 { |
|
638 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
639 TInt stopCode = ExtractErrorCode(iContext.iMessage); |
|
640 |
|
641 iContext.iNodeActivity->PostRequestTo(iContext.NodeId(), |
|
642 TCFDataClient::TStop(stopCode).CRef()); |
|
643 } |
|
644 |
|
645 //Awaiting one data client stopped |
|
646 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientStopped, NetStateMachine::MState, PRStates::TContext) |
|
647 EXPORT_C TBool TAwaitingDataClientStopped::Accept() |
|
648 { |
|
649 TCFDataClient::TStopped* dcStopped = message_cast<TCFDataClient::TStopped>(&iContext.iMessage); |
|
650 if (dcStopped == NULL) |
|
651 { |
|
652 return EFalse; |
|
653 } |
|
654 if (iContext.iPeer) |
|
655 { |
|
656 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
657 } |
|
658 if (iContext.iNodeActivity && |
|
659 (iContext.iNodeActivity->ActivitySigId() == ECFActivityStop || |
|
660 iContext.iNodeActivity->ActivitySigId() == ECFActivityStopDataClient)) |
|
661 { |
|
662 iContext.iNodeActivity->SetError(dcStopped->iValue); |
|
663 } |
|
664 return ETrue; |
|
665 } |
|
666 |
|
667 //Awaiting all of the data clients stopped |
|
668 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientsStopped, NetStateMachine::MState, PRStates::TContext) |
|
669 EXPORT_C TBool TAwaitingDataClientsStopped::Accept() |
|
670 { |
|
671 TCFDataClient::TStopped* dcStopped = message_cast<TCFDataClient::TStopped>(&iContext.iMessage); |
|
672 if (dcStopped == NULL) |
|
673 { |
|
674 return EFalse; |
|
675 } |
|
676 if (iContext.iPeer) |
|
677 { |
|
678 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
679 } |
|
680 if (iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EStarted))) |
|
681 { |
|
682 //There are more to wait for |
|
683 iContext.iMessage.ClearMessageId(); |
|
684 return EFalse; |
|
685 } |
|
686 if (iContext.iNodeActivity && |
|
687 (iContext.iNodeActivity->ActivitySigId() == ECFActivityStop || |
|
688 iContext.iNodeActivity->ActivitySigId() == ECFActivityStopDataClient)) |
|
689 { |
|
690 iContext.iNodeActivity->SetError(dcStopped->iValue); |
|
691 } |
|
692 //Last one - accept |
|
693 return ETrue; |
|
694 } |
|
695 |
|
696 EXPORT_DEFINE_SMELEMENT(TSendStop, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
697 EXPORT_C void TSendStop::DoL() |
|
698 { |
|
699 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
700 __ASSERT_DEBUG(iContext.Node().ServiceProvider(), CorePrPanic(KPanicNoServiceProvider)); |
|
701 |
|
702 TInt stopCode = ExtractErrorCode(iContext.iMessage); |
|
703 |
|
704 iContext.iNodeActivity->PostRequestTo(*iContext.Node().ServiceProvider(), TCFServiceProvider::TStop(stopCode).CRef()); |
|
705 } |
|
706 |
|
707 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientGoneDown, NetStateMachine::MState, PRStates::TContext) |
|
708 EXPORT_C TBool TAwaitingDataClientGoneDown::Accept() |
|
709 { |
|
710 if (! iContext.iMessage.IsMessage<TCFControlProvider::TDataClientGoneDown>()) |
|
711 { |
|
712 return EFalse; |
|
713 } |
|
714 |
|
715 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 16)); //This is a peer message |
|
716 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
717 return ETrue; |
|
718 } |
|
719 |
|
720 //-========================================================= |
|
721 // |
|
722 //NoBearer |
|
723 // |
|
724 //-========================================================= |
|
725 |
|
726 EXPORT_DEFINE_SMELEMENT(TAwaitingNoBearer, NetStateMachine::MState, CoreNetStates::TContext) |
|
727 EXPORT_C TBool TAwaitingNoBearer::Accept() |
|
728 { |
|
729 return iContext.iMessage.IsMessage<TCFControlProvider::TNoBearer>(); |
|
730 } |
|
731 |
|
732 EXPORT_DEFINE_SMELEMENT(TSendNoBearer, NetStateMachine::MStateTransition, PRStates::TContext) |
|
733 EXPORT_C void TSendNoBearer::DoL() |
|
734 { |
|
735 __ASSERT_DEBUG(iContext.Node().ServiceProvider()==NULL, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
736 RNodeInterface* ctrlProvider = iContext.Node().ControlProvider(); |
|
737 __ASSERT_DEBUG(ctrlProvider, CorePrPanic(KPanicNoControlProvider)); |
|
738 User::LeaveIfError(ctrlProvider? KErrNone : KErrCorrupt); |
|
739 iContext.iNodeActivity->PostRequestTo(*ctrlProvider, TCFControlProvider::TNoBearer().CRef()); |
|
740 } |
|
741 |
|
742 EXPORT_DEFINE_SMELEMENT(TSendBindTo, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
743 EXPORT_C void TSendBindTo::DoL() |
|
744 { |
|
745 //This is assumed to be executed as a direct response to TCommsBinderResponse |
|
746 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
747 |
|
748 //Create a binder to send. |
|
749 TCFServiceProvider::TCommsBinderResponse& binderResponse = message_cast<TCFServiceProvider::TCommsBinderResponse>(iContext.iMessage); |
|
750 |
|
751 //TODO: TNodePeerId should become internal. When this happens, FirstOriginator should return |
|
752 // RNodeInterface. |
|
753 iContext.iNodeActivity->PostRequestTo( |
|
754 address_cast<Messages::TNodeId>(iContext.iNodeActivity->SoleOriginator().RecipientId()), |
|
755 TCFDataClient::TBindTo(binderResponse.iNodeId).CRef()); |
|
756 } |
|
757 |
|
758 EXPORT_DEFINE_SMELEMENT(TSendBearer, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
759 EXPORT_C void TSendBearer::DoL() |
|
760 { |
|
761 if (iContext.iNodeActivity) |
|
762 { |
|
763 iContext.iNodeActivity->PostToOriginators(TCFControlProvider::TBearer().CRef()); |
|
764 } |
|
765 else |
|
766 { |
|
767 RClientInterface::OpenPostMessageClose(iContext.NodeId(), iContext.iSender, TCFControlProvider::TBearer().CRef()); |
|
768 } |
|
769 } |
|
770 |
|
771 EXPORT_DEFINE_SMELEMENT(TSendControlClientJoinRequest, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
772 EXPORT_C void TSendControlClientJoinRequest::DoL() |
|
773 { |
|
774 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
775 |
|
776 //The transition can be placed after (to process) the following messages: |
|
777 |
|
778 //(1)TCFDataClient::TBindTo - carrying the new service provider for this node. |
|
779 const TCFDataClient::TBindTo* bindToMsg(message_cast<const TCFDataClient::TBindTo>(&iContext.iMessage)); |
|
780 //(2)TCFServiceProvider::TCommsBinderResponse - carrying the auxilary service provider for this node (this node |
|
781 //may sometimes want to join the data client of its service provider. |
|
782 const TCFServiceProvider::TCommsBinderResponse* binderResponseMsg(message_cast<const TCFServiceProvider::TCommsBinderResponse>(&iContext.iMessage)); |
|
783 |
|
784 __ASSERT_DEBUG(bindToMsg || binderResponseMsg , User::Panic(KSpecAssert_ESockCrStaCPRSC, 17)); |
|
785 |
|
786 TNodeId newServiceProvider = bindToMsg ? bindToMsg->iNodeId : binderResponseMsg->iNodeId; |
|
787 RNodeInterface* sp = iContext.Node().AddClientL(newServiceProvider, TClientType(TCFClientType::EServProvider, TCFClientType::EActive)); |
|
788 __ASSERT_DEBUG(sp != NULL, CorePrPanic(KPanicNoServiceProvider)); |
|
789 User::LeaveIfError(sp? KErrNone : KErrCorrupt); |
|
790 |
|
791 //Join the service provider |
|
792 iContext.iNodeActivity->PostRequestTo(*sp, TCFPeer::TJoinRequest(iContext.NodeId(), TClientType(TCFClientType::ECtrl)).CRef()); |
|
793 } |
|
794 |
|
795 EXPORT_DEFINE_SMELEMENT(TRequestCommsBinder, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
796 EXPORT_C void TRequestCommsBinder::DoL() |
|
797 { |
|
798 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
799 |
|
800 RNodeInterface* sp = iContext.Node().ServiceProvider(); |
|
801 __ASSERT_DEBUG(sp != NULL, CorePrPanic(KPanicNoServiceProvider)); |
|
802 User::LeaveIfError(sp? KErrNone : KErrCorrupt); |
|
803 |
|
804 iContext.iNodeActivity->PostRequestTo(*sp, TCFServiceProvider::TCommsBinderRequest().CRef()); |
|
805 } |
|
806 |
|
807 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientStarted, NetStateMachine::MState, CoreStates::TContext) |
|
808 EXPORT_C TBool TAwaitingDataClientStarted::Accept() |
|
809 { |
|
810 if (iContext.iMessage.IsMessage<TCFDataClient::TStarted>()) |
|
811 { |
|
812 __ASSERT_DEBUG(iContext.iPeer || iContext.iSender == iContext.NodeId(), User::Panic(KSpecAssert_ESockCrStaCPRSC, 18)); |
|
813 if (iContext.iPeer) |
|
814 { |
|
815 iContext.iPeer->ClearFlags(TCFClientType::EStarting); |
|
816 iContext.iPeer->SetFlags(TCFClientType::EStarted); |
|
817 } |
|
818 return ETrue; |
|
819 } |
|
820 |
|
821 //If this is TError, clean the EStarting flag but do not accept, clean or otherwise process |
|
822 if (iContext.iMessage.IsMessage<TEBase::TError>()) |
|
823 { |
|
824 if (iContext.iPeer) |
|
825 { |
|
826 iContext.iPeer->ClearFlags(TCFClientType::EStarting); |
|
827 } |
|
828 } |
|
829 |
|
830 return EFalse; |
|
831 } |
|
832 |
|
833 // Status in which it waits for all the DataClients which haven't yet Started (flagged as "Starting") to Start |
|
834 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientsStarted, NetStateMachine::MState, PRStates::TContext) |
|
835 EXPORT_C TBool TAwaitingDataClientsStarted::Accept() |
|
836 { |
|
837 CoreNetStates::TAwaitingDataClientStarted state(iContext); |
|
838 if (state.Accept()) |
|
839 { |
|
840 if (iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData,TCFClientType::EStarting))) |
|
841 /* Meaning of the line above: 'Do I have any dataclient which has already sent the TStartDataClient message to but hasn't |
|
842 answered with TStarted yet?' */ |
|
843 { |
|
844 // YES, so there are more to wait for |
|
845 iContext.iMessage.ClearMessageId(); |
|
846 return EFalse; |
|
847 } |
|
848 return ETrue; |
|
849 } |
|
850 return EFalse; |
|
851 } |
|
852 |
|
853 //-========================================================= |
|
854 // |
|
855 //Destroy |
|
856 // |
|
857 //-========================================================= |
|
858 |
|
859 EXPORT_DEFINE_SMELEMENT(TAbortAllActivitiesNodeDeletion, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
860 EXPORT_C void TAbortAllActivitiesNodeDeletion::DoL() |
|
861 {//aborts all running activities fr all originator except me |
|
862 iContext.Node().AbortActivitiesOriginatedBy(iContext, TNodeId::NullId(), ETrue); |
|
863 } |
|
864 |
|
865 EXPORT_DEFINE_SMELEMENT(TAbortAllActivities, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
866 EXPORT_C void TAbortAllActivities::DoL() |
|
867 {//aborts all running activities fr all originator except me |
|
868 iContext.Node().AbortActivitiesOriginatedBy(iContext); |
|
869 } |
|
870 |
|
871 EXPORT_DEFINE_SMELEMENT(TSetIdleIfNoServiceProviders, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
872 EXPORT_C void TSetIdleIfNoServiceProviders::DoL() |
|
873 { |
|
874 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
875 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider))==NULL) |
|
876 { |
|
877 iContext.iNodeActivity->SetIdle(); |
|
878 } |
|
879 } |
|
880 |
|
881 EXPORT_DEFINE_SMELEMENT(TSetIdleIfMoreClients, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
882 EXPORT_C void TSetIdleIfMoreClients::DoL() |
|
883 { |
|
884 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
885 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl|TCFClientType::EData))!=NULL) |
|
886 { |
|
887 iContext.iNodeActivity->SetIdle(); |
|
888 } |
|
889 } |
|
890 |
|
891 EXPORT_DEFINE_SMELEMENT(TSendClientLeavingAndRemoveControlProvider, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
892 EXPORT_C void TSendClientLeavingAndRemoveControlProvider::DoL() |
|
893 { |
|
894 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrlProvider)); |
|
895 RNodeInterface* cl = iter[0]; |
|
896 //It is perfectly possible that there is no Control Provider at all. |
|
897 if (cl) |
|
898 { |
|
899 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
900 cl->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), TEChild::TLeft().CRef()); |
|
901 iContext.Node().RemoveClient(cl->RecipientId(),iContext); |
|
902 __ASSERT_DEBUG(iter[1] == NULL, User::Panic(KSpecAssert_ESockCrStaCPRSC, 19)); //But it is not possible to have two Control Providers! |
|
903 } |
|
904 } |
|
905 |
|
906 EXPORT_DEFINE_SMELEMENT(TSendClientLeavingAndRemoveControlProviderIfNoServiceProviders, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
907 EXPORT_C void TSendClientLeavingAndRemoveControlProviderIfNoServiceProviders::DoL() |
|
908 { |
|
909 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
910 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider))==NULL) |
|
911 { |
|
912 TSendClientLeavingAndRemoveControlProvider::DoL(); |
|
913 } |
|
914 } |
|
915 |
|
916 EXPORT_DEFINE_SMELEMENT(TSendClientLeavingRequestToServiceProviders, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
917 EXPORT_C void TSendClientLeavingRequestToServiceProviders::DoL() |
|
918 { |
|
919 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
920 |
|
921 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider)); |
|
922 for (TInt i = 0; iter[i]; i++) |
|
923 { |
|
924 RNodeInterface* cl = iter[i]; |
|
925 |
|
926 // Do not send client leaving requests to service providers which are already leaving |
|
927 // (e.g., gone down). |
|
928 if (!(cl->Flags() & TClientType::ELeaving)) |
|
929 { |
|
930 cl->PostMessage( |
|
931 TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
932 TEPeer::TLeaveRequest().CRef() |
|
933 ); |
|
934 |
|
935 //We are expecting answers from many service providers, set to NullCommsId. |
|
936 iContext.iNodeActivity->ClearPostedTo(); |
|
937 iter[i]->SetFlags(TCFClientType::ELeaving); |
|
938 } |
|
939 else |
|
940 { |
|
941 MESH_LOG((KCoreProviderStatesSubTag, _L8("TSendClientLeavingRequestToServiceProviders:\tDoL - IGNORING POST!"))); |
|
942 } |
|
943 } |
|
944 } |
|
945 |
|
946 EXPORT_DEFINE_SMELEMENT(TSendClientLeavingRequestToServiceProvider, NetStateMachine::MStateTransition, CoreStates::TContext) |
|
947 EXPORT_C void TSendClientLeavingRequestToServiceProvider::DoL() |
|
948 { |
|
949 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
950 |
|
951 //If the sender is a service provider, send to it (there may be more than one) |
|
952 RNodeInterface* sp = iContext.Node().FindClient(iContext.iSender); |
|
953 if (sp == NULL || !(sp->Type()&TCFClientType::EServProvider)) |
|
954 { |
|
955 //Otherwise there must be only one sp on the node |
|
956 TClientIter<TDefaultClientMatchPolicy> servProviders = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider)); |
|
957 __ASSERT_DEBUG(servProviders[0] && servProviders[1] == NULL, CorePrPanic(KPanicNoServiceProvider)); |
|
958 sp = servProviders[0]; |
|
959 } |
|
960 |
|
961 __ASSERT_DEBUG(sp, CorePrPanic(KPanicNoServiceProvider)); |
|
962 iContext.iNodeActivity->PostRequestTo(*sp, |
|
963 TEPeer::TLeaveRequest().CRef()); |
|
964 sp->SetFlags(TCFClientType::ELeaving); |
|
965 } |
|
966 |
|
967 //-========================================================= |
|
968 // |
|
969 //Service Provider Going Up |
|
970 // |
|
971 //-========================================================= |
|
972 DEFINE_SMELEMENT(TAwaitingGoneUp, NetStateMachine::MState, CoreStates::TContext) |
|
973 TBool TAwaitingGoneUp::Accept() |
|
974 { |
|
975 if (! iContext.iMessage.IsMessage<TCFControlClient::TGoneUp>()) |
|
976 { |
|
977 return EFalse; |
|
978 } |
|
979 iContext.iPeer->SetFlags(TCFClientType::EStarted); |
|
980 return ETrue; |
|
981 } |
|
982 |
|
983 |
|
984 //-========================================================= |
|
985 // |
|
986 //Service Provider Going Down |
|
987 // |
|
988 //-========================================================= |
|
989 EXPORT_DEFINE_SMELEMENT(TAwaitingGoneDown, NetStateMachine::MState, CoreStates::TContext) |
|
990 EXPORT_C TBool TAwaitingGoneDown::Accept() |
|
991 { |
|
992 if (! iContext.iMessage.IsMessage<TCFControlClient::TGoneDown>()) |
|
993 { |
|
994 return EFalse; |
|
995 } |
|
996 if (iContext.iPeer) |
|
997 { |
|
998 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
999 } |
|
1000 if (iContext.Node().CountActivities(ECFActivityStop) || |
|
1001 iContext.Node().CountActivities(ECFActivityStopDataClient) || |
|
1002 iContext.Node().CountActivities(ECFActivityDestroy)) |
|
1003 { |
|
1004 //we're already stopping - eat the message |
|
1005 iContext.iMessage.ClearMessageId(); |
|
1006 return EFalse; |
|
1007 } |
|
1008 return ETrue; |
|
1009 } |
|
1010 |
|
1011 EXPORT_DEFINE_SMELEMENT(TSendClientLeavingAndRemoveServiceProvider, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1012 EXPORT_C void TSendClientLeavingAndRemoveServiceProvider::DoL() |
|
1013 { |
|
1014 //This must be a peer message |
|
1015 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 20)); |
|
1016 |
|
1017 if (iContext.Node().ServiceProvider()) |
|
1018 { |
|
1019 //Activity id does not matter for TClientLeaving message since there is no response to it. |
|
1020 //Please do not ASSERT(iContext.iNodeActivity) here! |
|
1021 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
1022 TEChild::TLeft().CRef(), TClientType(TCFClientType::EServProvider)); |
|
1023 // we should usually set the ELeaving flag on the RNodeInterface since we've sent ClientLeaving to |
|
1024 // the node, but there's no need here, as the client is being deleted anyhow. |
|
1025 iContext.Node().RemoveClient(iContext.Node().ServiceProvider()->RecipientId(),iContext); |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 //-========================================================= |
|
1030 // |
|
1031 //Other |
|
1032 // |
|
1033 //-========================================================= |
|
1034 |
|
1035 EXPORT_DEFINE_SMELEMENT(TAwaitingStopped, NetStateMachine::MState, CoreNetStates::TContext) |
|
1036 EXPORT_C TBool TAwaitingStopped::Accept() |
|
1037 { |
|
1038 if (! iContext.iMessage.IsMessage<TCFServiceProvider::TStopped>() ) |
|
1039 { |
|
1040 return EFalse; |
|
1041 } |
|
1042 |
|
1043 if (iContext.iPeer) |
|
1044 { |
|
1045 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
1046 } |
|
1047 return ETrue; |
|
1048 } |
|
1049 |
|
1050 EXPORT_DEFINE_SMELEMENT(TAwaitingStop, NetStateMachine::MState, CoreNetStates::TContext) |
|
1051 TBool TAwaitingStop::Accept() |
|
1052 { |
|
1053 if (!iContext.iMessage.IsMessage<TCFServiceProvider::TStop>()) |
|
1054 { |
|
1055 return EFalse; |
|
1056 } |
|
1057 if (iContext.Node().ServiceProvider()) |
|
1058 { |
|
1059 iContext.Node().ServiceProvider()->SetFlags(TCFClientType::EStarted); |
|
1060 } |
|
1061 return ETrue; |
|
1062 } |
|
1063 |
|
1064 EXPORT_DEFINE_SMELEMENT(TAwaitingParamResponse, NetStateMachine::MState, CoreStates::TContext) |
|
1065 EXPORT_C TBool TAwaitingParamResponse::Accept() |
|
1066 { |
|
1067 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1068 if((iContext.iMessage.IsMessage<TCFScpr::TSetParamsResponse>()) || (iContext.iMessage.IsMessage<TCFScpr::TGetParamsResponse>())) |
|
1069 { |
|
1070 return ETrue; |
|
1071 } |
|
1072 return EFalse; |
|
1073 #else |
|
1074 return iContext.iMessage.IsMessage<TCFScpr::TParamsResponse>(); |
|
1075 #endif // SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1076 } |
|
1077 |
|
1078 EXPORT_DEFINE_SMELEMENT(TRespondWithRetrievedParams, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1079 EXPORT_C void TRespondWithRetrievedParams::DoL() |
|
1080 { |
|
1081 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1082 iContext.PostToSender(TCFScpr::TGetParamsResponse(iContext.Node().iParameterBundle).CRef()); |
|
1083 #endif |
|
1084 } |
|
1085 |
|
1086 EXPORT_DEFINE_SMELEMENT(TAwaitingConEvent, NetStateMachine::MState, CoreStates::TContext) |
|
1087 EXPORT_C TBool TAwaitingConEvent::Accept() |
|
1088 { |
|
1089 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1090 return iContext.iMessage.IsMessage<TCFSubConnControlClient::TPlaneNotification>(); |
|
1091 #else |
|
1092 return EFalse; |
|
1093 #endif |
|
1094 } |
|
1095 |
|
1096 EXPORT_DEFINE_SMELEMENT(TAwaitingSubConEvent, NetStateMachine::MState, CoreStates::TContext) |
|
1097 EXPORT_C TBool TAwaitingSubConEvent::Accept() |
|
1098 { |
|
1099 return iContext.iMessage.IsMessage<TCFSubConnControlClient::TSubConnNotification>(); |
|
1100 } |
|
1101 |
|
1102 |
|
1103 |
|
1104 //-========================================================= |
|
1105 // |
|
1106 //Binder request |
|
1107 // |
|
1108 //-========================================================= |
|
1109 |
|
1110 EXPORT_DEFINE_SMELEMENT(TAwaitingBinderRequest, NetStateMachine::MState, PRStates::TContext) |
|
1111 EXPORT_C TBool TAwaitingBinderRequest::Accept() |
|
1112 { |
|
1113 if (! iContext.iMessage.IsMessage<TCFServiceProvider::TCommsBinderRequest>()) |
|
1114 { |
|
1115 return EFalse; |
|
1116 } |
|
1117 |
|
1118 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 21)); //TCommsBinderRequest is a peer message only! |
|
1119 return ETrue; |
|
1120 } |
|
1121 |
|
1122 // Start all the DataClients |
|
1123 EXPORT_DEFINE_SMELEMENT(TStartDataClients, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1124 EXPORT_C void TStartDataClients::DoL() |
|
1125 { |
|
1126 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1127 |
|
1128 //there should be a panic if we don't have any dataclients which are NOT in in EStarting or in EStarted state. |
|
1129 //Reason: there is no dataclients which is possible to start (because all of them have been already started). Then why are we here????? |
|
1130 TInt cliNum = iContext.Node().CountClients<TExcludeTypeAndFlagClientMatchPolicy>( |
|
1131 TClientType( |
|
1132 TCFClientType::EData, |
|
1133 (TCFClientType::EStarted | TCFClientType::EStarting | TCFClientType::ELeaving) |
|
1134 ) |
|
1135 ); |
|
1136 |
|
1137 // TODO When called from SCprNoBearer before the node is started the node is panic'ed. |
|
1138 // Rather than panic, ensure that the node is started and thus the service provider is started. |
|
1139 // Thus started dataclients can be ignored. |
|
1140 // __ASSERT_DEBUG(cliNum != 0, CorePrPanic(KNoClients)); |
|
1141 |
|
1142 if (cliNum > 0) |
|
1143 { |
|
1144 //start all of the dataclients which haven't been started yet |
|
1145 TClientIter<TExcludeTypeAndFlagClientMatchPolicy> iter = iContext.Node().GetClientIter<TExcludeTypeAndFlagClientMatchPolicy>( |
|
1146 TClientType( |
|
1147 TCFClientType::EData, |
|
1148 (TCFClientType::EStarted | TCFClientType::EStarting | TCFClientType::ELeaving) |
|
1149 ) |
|
1150 ); |
|
1151 |
|
1152 RNodeInterface* ctl = NULL; |
|
1153 while ((ctl = iter++) != NULL) |
|
1154 { |
|
1155 iContext.iNodeActivity->PostRequestTo(*ctl, TCFDataClient::TStart().CRef()); |
|
1156 ctl->SetFlags(TCFClientType::EStarting); |
|
1157 } |
|
1158 } |
|
1159 else |
|
1160 { |
|
1161 // Self Post TStarted if no clients need to be started. |
|
1162 iContext.iNodeActivity->PostRequestTo(iContext.NodeId(), TCFDataClient::TStarted().CRef()); |
|
1163 } |
|
1164 |
|
1165 if (cliNum >1) |
|
1166 { |
|
1167 iContext.iNodeActivity->ClearPostedTo(); |
|
1168 } |
|
1169 } |
|
1170 |
|
1171 EXPORT_DEFINE_SMELEMENT(TSendDataClientStarted, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1172 EXPORT_C void TSendDataClientStarted::DoL() |
|
1173 { |
|
1174 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1175 iContext.iNodeActivity->PostToOriginators(TCFDataClient::TStarted().CRef()); |
|
1176 |
|
1177 // Tell control provider that we have started.. for Tier Notification |
|
1178 |
|
1179 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
1180 TCFControlProvider::TDataClientStatusChange(TCFControlProvider::TDataClientStatusChange::EStarted).CRef(), TClientType(TCFClientType::ECtrlProvider)); |
|
1181 } |
|
1182 |
|
1183 EXPORT_DEFINE_SMELEMENT(TStartServiceProvider, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1184 EXPORT_C void TStartServiceProvider::DoL() |
|
1185 { |
|
1186 RNodeInterface* sp = iContext.Node().ServiceProvider(); |
|
1187 __ASSERT_DEBUG(sp, CorePrPanic(KPanicNoServiceProvider)); |
|
1188 User::LeaveIfError(sp? KErrNone : KErrCorrupt); |
|
1189 |
|
1190 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1191 iContext.iNodeActivity->PostRequestTo(*sp, TCFServiceProvider::TStart().CRef()); |
|
1192 |
|
1193 sp->SetFlags(TCFClientType::EStarting); |
|
1194 } |
|
1195 |
|
1196 //-========================================================= |
|
1197 // |
|
1198 // Send TGoneUp |
|
1199 // |
|
1200 //-========================================================= |
|
1201 DEFINE_SMELEMENT(TSendGoneUp, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1202 void TSendGoneUp::DoL() |
|
1203 { |
|
1204 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl)); |
|
1205 for (TInt i = 0; iter[i]; i++) |
|
1206 { |
|
1207 //Send TGoneUp to every Ctrl client except the originator (who would be recieving TStarted) |
|
1208 if ((iContext.iNodeActivity && iContext.iNodeActivity->FindOriginator(*iter[i]) != KErrNone) |
|
1209 && iter[i] != iContext.iPeer) |
|
1210 { |
|
1211 iter[i]->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), TCFControlClient::TGoneUp()); |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 EXPORT_DEFINE_SMELEMENT(TSendStarted, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1217 EXPORT_C void TSendStarted::DoL() |
|
1218 { |
|
1219 TCFServiceProvider::TStarted msg; |
|
1220 if (iContext.iNodeActivity) |
|
1221 { |
|
1222 iContext.iNodeActivity->PostToOriginators(msg); |
|
1223 |
|
1224 TSendGoneUp(iContext).DoL(); |
|
1225 } |
|
1226 else |
|
1227 { |
|
1228 //This transition can also be used from a single tripple activity |
|
1229 iContext.PostToSender(msg); |
|
1230 |
|
1231 TSendGoneUp(iContext).DoL(); |
|
1232 } |
|
1233 } |
|
1234 |
|
1235 EXPORT_DEFINE_SMELEMENT(TPassPlaneEventToControlClients, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1236 EXPORT_C void TPassPlaneEventToControlClients::DoL() |
|
1237 { |
|
1238 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1239 TCFSubConnControlClient::TPlaneNotification& event = message_cast<TCFSubConnControlClient::TPlaneNotification>(iContext.iMessage); |
|
1240 |
|
1241 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl)); |
|
1242 RNodeInterface* ctl; |
|
1243 while ((ctl = iter++) != NULL) |
|
1244 { |
|
1245 event.iRefCountOwnedNotification->Open(); |
|
1246 ctl->PostMessage(iContext.NodeId(), event); |
|
1247 } |
|
1248 |
|
1249 // This Close() matches the Open performed by the service provider node Open() function |
|
1250 event.iRefCountOwnedNotification->Close(); |
|
1251 #endif |
|
1252 } |
|
1253 |
|
1254 EXPORT_DEFINE_SMELEMENT(TSendStopped, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1255 EXPORT_C void TSendStopped::DoL() |
|
1256 { |
|
1257 //Please note that PostToOriginators overwrites the activity id, |
|
1258 //RNodeInterface::PostMessage does not! |
|
1259 TCFServiceProvider::TStopped msg(KErrNone); |
|
1260 if (iContext.iNodeActivity) |
|
1261 { |
|
1262 iContext.iNodeActivity->PostToOriginators(msg); |
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 //This transition can also be used from a single tripple activity |
|
1267 iContext.PostToSender(msg); |
|
1268 } |
|
1269 } |
|
1270 |
|
1271 EXPORT_DEFINE_SMELEMENT(TSendStoppedAndGoneDown, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1272 EXPORT_C void TSendStoppedAndGoneDown::DoL() |
|
1273 { |
|
1274 TInt stopCode = ExtractErrorCode(iContext.iMessage, iContext.iNodeActivity); |
|
1275 |
|
1276 //Please note that PostToOriginators overwrites the activity id, |
|
1277 //RNodeInterface::PostMessage does not! |
|
1278 TCFServiceProvider::TStopped msg(stopCode); |
|
1279 if (iContext.iNodeActivity) |
|
1280 { |
|
1281 iContext.iNodeActivity->PostToOriginators(msg); |
|
1282 } |
|
1283 else |
|
1284 { |
|
1285 //This transition can also be used from a single tripple activity |
|
1286 iContext.PostToSender(msg); |
|
1287 } |
|
1288 |
|
1289 const TProviderInfo& providerInfo = static_cast<const TProviderInfoExt&>(iContext.Node().AccessPointConfig().FindExtensionL( |
|
1290 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))).iProviderInfo; |
|
1291 |
|
1292 TCFControlClient::TGoneDown goneDown(stopCode, providerInfo.APId()); |
|
1293 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl)); |
|
1294 for (TInt i = 0; iter[i]; i++) |
|
1295 { |
|
1296 CNodeActivityBase* startActivity = iContext.Node().FindActivityById(ECFActivityStart); |
|
1297 |
|
1298 //Send TGoneDown to every Ctrl client except |
|
1299 // * the originator (who would be recieving TStopped) |
|
1300 // * originators of the start activity (these will be errored separately) |
|
1301 if (((iContext.iNodeActivity && iContext.iNodeActivity->FindOriginator(*iter[i]) != KErrNone) || |
|
1302 (iContext.iNodeActivity == NULL && iter[i] != iContext.iPeer)) |
|
1303 && (startActivity == NULL || startActivity->FindOriginator(*iter[i]) != KErrNone)) |
|
1304 { |
|
1305 iter[i]->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), goneDown); |
|
1306 } |
|
1307 } |
|
1308 |
|
1309 if (iContext.iNodeActivity) |
|
1310 { |
|
1311 iContext.iNodeActivity->SetError(KErrNone); |
|
1312 } |
|
1313 } |
|
1314 |
|
1315 EXPORT_DEFINE_SMELEMENT(TAwaitingStarted, NetStateMachine::MState, CoreNetStates::TContext) |
|
1316 EXPORT_C TBool TAwaitingStarted::Accept() |
|
1317 { |
|
1318 if (iContext.iMessage.IsMessage<TCFServiceProvider::TStarted>()) |
|
1319 { |
|
1320 if (iContext.iPeer) |
|
1321 { |
|
1322 iContext.iPeer->ClearFlags(TCFClientType::EStarting); |
|
1323 iContext.iPeer->SetFlags(TCFClientType::EStarted); |
|
1324 } |
|
1325 return ETrue; |
|
1326 } |
|
1327 |
|
1328 //If this is TError, clean the EStarting flag but do not accept, clean or otherwise process |
|
1329 if (iContext.iMessage.IsMessage<TEBase::TError>()) |
|
1330 { |
|
1331 if (iContext.iPeer) |
|
1332 { |
|
1333 iContext.iPeer->ClearFlags(TCFClientType::EStarting); |
|
1334 } |
|
1335 } |
|
1336 |
|
1337 return EFalse; |
|
1338 } |
|
1339 |
|
1340 EXPORT_DEFINE_SMELEMENT(TSendBindToComplete, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1341 EXPORT_C void TSendBindToComplete::DoL() |
|
1342 { |
|
1343 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1344 iContext.iNodeActivity->PostToOriginators(TCFDataClient::TBindToComplete(iContext.iNodeActivity->Error()).CRef()); |
|
1345 } |
|
1346 |
|
1347 EXPORT_DEFINE_SMELEMENT(TBindSelfToPresentBearer, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1348 EXPORT_C void TBindSelfToPresentBearer::DoL() |
|
1349 { |
|
1350 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1351 |
|
1352 __ASSERT_DEBUG(iContext.Node().ServiceProvider(), User::Panic(KSpecAssert_ESockCrStaCPRSC, 22)); |
|
1353 TNodeId bearer = iContext.Node().ServiceProvider()->RecipientId(); |
|
1354 iContext.iNodeActivity->PostRequestTo(iContext.NodeId(), TCFDataClient::TBindTo(bearer).CRef()); |
|
1355 } |
|
1356 |
|
1357 EXPORT_DEFINE_SMELEMENT(TBindSelf, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1358 EXPORT_C void TBindSelf::DoL() |
|
1359 { |
|
1360 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1361 const TCFDataClient::TBindTo& bindToMessage = message_cast<TCFDataClient::TBindTo>(iContext.iMessage); |
|
1362 iContext.iNodeActivity->PostRequestTo(iContext.NodeId(), TCFDataClient::TBindTo(bindToMessage.iNodeId).CRef()); |
|
1363 } |
|
1364 |
|
1365 EXPORT_DEFINE_SMELEMENT(TStartSelf, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
1366 EXPORT_C void TStartSelf::DoL() |
|
1367 { |
|
1368 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1369 iContext.iNodeActivity->PostRequestTo(iContext.NodeId(), TCFDataClient::TStart().CRef()); |
|
1370 } |
|
1371 |
|
1372 EXPORT_DEFINE_SMELEMENT(TStoreParams, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1373 EXPORT_C void TStoreParams::DoL() |
|
1374 { |
|
1375 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1376 if (iContext.Node().CountActivities(ECFActivityApplyChanges)) |
|
1377 { |
|
1378 User::Leave(KErrInUse); |
|
1379 } |
|
1380 TCFScpr::TSetParamsRequest* setParamsRequest = message_cast<TCFScpr::TSetParamsRequest>(&iContext.iMessage); |
|
1381 TCFScpr::TSetParamsResponse* setParamsResponse = message_cast<TCFScpr::TSetParamsResponse>(&iContext.iMessage); |
|
1382 __ASSERT_DEBUG(setParamsRequest || setParamsResponse, User::Panic(KSpecAssert_ESockCrStaCPRSC, 23)); |
|
1383 |
|
1384 RCFParameterFamilyBundleC newParamBundle = setParamsRequest ? setParamsRequest->iFamilyBundle : setParamsResponse->iFamilyBundle; |
|
1385 |
|
1386 if ( ! newParamBundle.IsNull() |
|
1387 && (iContext.Node().iParameterBundle.IsNull() || |
|
1388 iContext.Node().iParameterBundle != newParamBundle)) |
|
1389 { |
|
1390 if ( ! iContext.Node().iParameterBundle.IsNull()) |
|
1391 { |
|
1392 iContext.Node().iParameterBundle.Close(); |
|
1393 } |
|
1394 |
|
1395 iContext.Node().iParameterBundle.Open(newParamBundle); |
|
1396 } |
|
1397 #endif |
|
1398 } |
|
1399 |
|
1400 EXPORT_DEFINE_SMELEMENT(TRespondWithCurrentParams, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1401 EXPORT_C void TRespondWithCurrentParams::DoL() |
|
1402 { |
|
1403 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1404 TCFScpr::TSetParamsRequest& paramRequest = message_cast<TCFScpr::TSetParamsRequest>(iContext.iMessage); |
|
1405 if ( (! paramRequest.iFamilyBundle.IsNull()) && iContext.Node().iParameterBundle != paramRequest.iFamilyBundle ) |
|
1406 { |
|
1407 //default behaviour. Parameters where supplied, though haven't been processed |
|
1408 User::Leave(KErrNotSupported); |
|
1409 } |
|
1410 iContext.PostToSender(TCFScpr::TSetParamsResponse(iContext.Node().iParameterBundle).CRef()); |
|
1411 #endif |
|
1412 } |
|
1413 |
|
1414 EXPORT_DEFINE_SMELEMENT(TSendApplyResponse, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1415 EXPORT_C void TSendApplyResponse::DoL() |
|
1416 { |
|
1417 __ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 24)); |
|
1418 iContext.iNodeActivity->PostToOriginators(TCFScpr::TApplyResponse().CRef()); |
|
1419 } |
|
1420 |
|
1421 EXPORT_DEFINE_SMELEMENT(TPassToServiceProvider, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1422 EXPORT_C void TPassToServiceProvider::DoL() |
|
1423 { |
|
1424 //If you don't have the service provider, don't use this transition. |
|
1425 __ASSERT_DEBUG(iContext.Node().ServiceProvider(), User::Panic(KSpecAssert_ESockCrStaCPRSC, 25)); |
|
1426 __ASSERT_DEBUG(iContext.iNodeActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 26)); |
|
1427 iContext.iNodeActivity->PostRequestTo(*iContext.Node().ServiceProvider(), iContext.iMessage); |
|
1428 } |
|
1429 |
|
1430 |
|
1431 EXPORT_DEFINE_SMELEMENT(TSendParamsToServiceProvider, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1432 EXPORT_C void TSendParamsToServiceProvider::DoL() |
|
1433 { |
|
1434 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1435 __ASSERT_DEBUG( ! iContext.Node().iParameterBundle.IsNull(), User::Panic(KSpecAssert_ESockCrStaCPRSC, 27)); |
|
1436 iContext.iNodeActivity->PostRequestTo(*iContext.Node().ServiceProvider(), |
|
1437 TCFScpr::TSetParamsRequest(iContext.Node().iParameterBundle).CRef()); |
|
1438 #endif |
|
1439 } |
|
1440 |
|
1441 |
|
1442 //-========================================================= |
|
1443 // |
|
1444 //States |
|
1445 // |
|
1446 //-========================================================= |
|
1447 |
|
1448 // This allows an activity to hang (for cases where it must |
|
1449 // remain in existence in order to respond to a cancel) |
|
1450 EXPORT_DEFINE_SMELEMENT(TNeverAccept, NetStateMachine::MState, CoreStates::TContext) |
|
1451 EXPORT_C TBool TNeverAccept::Accept() |
|
1452 { |
|
1453 return EFalse; |
|
1454 } |
|
1455 |
|
1456 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientStart, NetStateMachine::MState, CoreNetStates::TContext) |
|
1457 EXPORT_C TBool TAwaitingDataClientStart::Accept() |
|
1458 { |
|
1459 return iContext.iMessage.IsMessage<TCFDataClient::TStart>(); |
|
1460 } |
|
1461 |
|
1462 EXPORT_DEFINE_SMELEMENT(TAwaitingStart, NetStateMachine::MState, CoreNetStates::TContext) |
|
1463 EXPORT_C TBool TAwaitingStart::Accept() |
|
1464 { |
|
1465 if (iContext.iMessage.IsMessage<TCFServiceProvider::TStart>()) |
|
1466 { |
|
1467 __ASSERT_DEBUG(iContext.iPeer || iContext.iSender == iContext.NodeId(), CorePrPanic(KPanicPeerMessage)); |
|
1468 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EStarted)) == NULL) |
|
1469 { |
|
1470 return ETrue; |
|
1471 } |
|
1472 |
|
1473 iContext.iPeer->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), TCFServiceProvider::TStarted().CRef()); |
|
1474 //Legacy progress notification - will hopefully be ignored by anything else than CConnection. |
|
1475 iContext.iPeer->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), TCFMessage::TStateChange(TStateChange(KLinkLayerOpen, KErrNone)).CRef()); |
|
1476 iContext.iMessage.ClearMessageId(); |
|
1477 } |
|
1478 return EFalse; |
|
1479 } |
|
1480 |
|
1481 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientStop, NetStateMachine::MState, CoreNetStates::TContext) |
|
1482 EXPORT_C TBool TAwaitingDataClientStop::Accept() |
|
1483 { |
|
1484 return iContext.iMessage.IsMessage<TCFDataClient::TStop>(); |
|
1485 } |
|
1486 |
|
1487 |
|
1488 EXPORT_DEFINE_SMELEMENT(TAwaitingBindTo, NetStateMachine::MState, CoreStates::TContext) |
|
1489 EXPORT_C TBool TAwaitingBindTo::Accept() |
|
1490 { |
|
1491 const TCFDataClient::TBindTo* bindToMessage = message_cast<TCFDataClient::TBindTo>(&iContext.iMessage); |
|
1492 if (bindToMessage) |
|
1493 { |
|
1494 //TBindTo is always a response. there's gotta be an activity. |
|
1495 if (iContext.iNodeActivity && iContext.iNodeActivity->SupportsExtInterface(ABindingActivity::KInterfaceId)) |
|
1496 { |
|
1497 ABindingActivity* bindingActivity = reinterpret_cast<ABindingActivity*>(iContext.iNodeActivity->FetchExtInterface(ABindingActivity::KInterfaceId)); |
|
1498 bindingActivity->StoreOriginator(iContext.iSender); |
|
1499 } |
|
1500 return ETrue; |
|
1501 } |
|
1502 return EFalse; |
|
1503 } |
|
1504 |
|
1505 EXPORT_DEFINE_SMELEMENT(TAwaitingBindToOrCancel, NetStateMachine::MState, CoreStates::TContext) |
|
1506 TBool TAwaitingBindToOrCancel::Accept() |
|
1507 { |
|
1508 TAwaitingBindTo st(iContext); |
|
1509 if (st.Accept()) |
|
1510 { |
|
1511 return ETrue; |
|
1512 } |
|
1513 if (iContext.iMessage.IsMessage<TEBase::TCancel>()) |
|
1514 { |
|
1515 iContext.iNodeActivity->SetError(KErrCancel); |
|
1516 iContext.iMessage.ClearMessageId(); |
|
1517 return EFalse; |
|
1518 } |
|
1519 return EFalse; |
|
1520 } |
|
1521 |
|
1522 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientJoin, NetStateMachine::MState, CoreNetStates::TContext) |
|
1523 EXPORT_C TBool TAwaitingDataClientJoin::Accept() |
|
1524 { |
|
1525 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1526 TCFFactory::TPeerFoundOrCreated* dcJoined = message_cast<TCFFactory::TPeerFoundOrCreated>(&iContext.iMessage); |
|
1527 if ( dcJoined ) |
|
1528 { |
|
1529 if (iContext.iNodeActivity->Error() != KErrNone) |
|
1530 { |
|
1531 TNodeCtxId returnId(iContext.ActivityId(), iContext.NodeId()); |
|
1532 |
|
1533 RNodeInterface* clientAlreadyAdded = iContext.Node().FindClient(dcJoined->iNodeId); |
|
1534 if (clientAlreadyAdded == NULL && !dcJoined->iNodeId.IsNull()) |
|
1535 { |
|
1536 RClientInterface::OpenPostMessageClose(returnId, dcJoined->iNodeId, TEChild::TDestroy().CRef()); |
|
1537 // Add the node to our client list to prevent the TLeft response to the TDestroy |
|
1538 // resulting in PRClientLeaveActivity failing to find the node and panicing. |
|
1539 iContext.Node().AddClientL(dcJoined->iNodeId, TClientType(TCFClientType::EData, TClientType::ELeaving)); |
|
1540 } |
|
1541 TEBase::TError simualtedErrorMessage(TCFFactory::TFindOrCreatePeer::Id(), |
|
1542 iContext.iNodeActivity->Error()); |
|
1543 |
|
1544 RClientInterface::OpenPostMessageClose(iContext.iSender, returnId, simualtedErrorMessage); |
|
1545 iContext.iMessage.ClearMessageId(); |
|
1546 return EFalse; |
|
1547 } |
|
1548 else |
|
1549 { |
|
1550 return ETrue; |
|
1551 } |
|
1552 } |
|
1553 else if (iContext.iMessage.IsMessage<TEBase::TCancel>()) |
|
1554 { |
|
1555 //We can't send TCancel to the factory, we better eat the message |
|
1556 //here and switch the activity into a cancelling mode. |
|
1557 iContext.iMessage.ClearMessageId(); |
|
1558 iContext.iNodeActivity->SetError(KErrCancel); |
|
1559 } |
|
1560 return EFalse; |
|
1561 } |
|
1562 |
|
1563 EXPORT_DEFINE_SMELEMENT(TAwaitingJoinComplete, NetStateMachine::MState, CoreStates::TContext) |
|
1564 EXPORT_C TBool TAwaitingJoinComplete::Accept() |
|
1565 { |
|
1566 if(iContext.iMessage.IsMessage<TCFPeer::TJoinComplete>()) |
|
1567 { |
|
1568 return ETrue; |
|
1569 } |
|
1570 else if(iContext.iMessage.IsMessage<TEBase::TError>()) |
|
1571 { |
|
1572 iContext.Node().RemoveClient(iContext.iSender); |
|
1573 } |
|
1574 return EFalse; |
|
1575 } |
|
1576 |
|
1577 EXPORT_DEFINE_SMELEMENT(TAwaitingBinderResponse, NetStateMachine::MState, CoreNetStates::TContext) |
|
1578 EXPORT_C TBool TAwaitingBinderResponse::Accept() |
|
1579 { |
|
1580 const TCFServiceProvider::TCommsBinderResponse* binderResponseMsg = message_cast<TCFServiceProvider::TCommsBinderResponse>(&iContext.iMessage); |
|
1581 if (binderResponseMsg) |
|
1582 { |
|
1583 if (iContext.iNodeActivity && iContext.iNodeActivity->SupportsExtInterface(ABindingActivity::KInterfaceId)) |
|
1584 { |
|
1585 ABindingActivity* bindingActivity = reinterpret_cast<ABindingActivity*>(iContext.iNodeActivity->FetchExtInterface(ABindingActivity::KInterfaceId)); |
|
1586 __ASSERT_DEBUG(bindingActivity, User::Panic(KSpecAssert_ESockCrStaCPRSC, 28)); |
|
1587 bindingActivity->StoreOriginator(iContext.iSender); |
|
1588 } |
|
1589 return ETrue; |
|
1590 } |
|
1591 return EFalse; |
|
1592 } |
|
1593 |
|
1594 EXPORT_DEFINE_SMELEMENT(CoreNetStates::TAwaitingBindToComplete, NetStateMachine::MState, CoreNetStates::TContext) |
|
1595 EXPORT_C TBool CoreNetStates::TAwaitingBindToComplete::Accept() |
|
1596 { |
|
1597 TCFDataClient::TBindToComplete* bindToComplete = message_cast<TCFDataClient::TBindToComplete>(&iContext.iMessage); |
|
1598 if (bindToComplete) |
|
1599 { |
|
1600 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1601 iContext.iNodeActivity->SetError(bindToComplete->iValue); |
|
1602 return ETrue; |
|
1603 } |
|
1604 return EFalse; |
|
1605 } |
|
1606 |
|
1607 EXPORT_DEFINE_SMELEMENT(TAwaitingProvision, NetStateMachine::MState, PRStates::TContext) |
|
1608 EXPORT_C TBool TAwaitingProvision::Accept() |
|
1609 { |
|
1610 return iContext.iMessage.IsMessage<TCFDataClient::TProvisionConfig>(); |
|
1611 } |
|
1612 |
|
1613 EXPORT_DEFINE_SMELEMENT(TAwaitingControlClientJoin, NetStateMachine::MState, PRStates::TContext) |
|
1614 EXPORT_C TBool TAwaitingControlClientJoin::Accept() |
|
1615 { |
|
1616 return iContext.iMessage.IsMessage<TCFFactory::TPeerFoundOrCreated>() |
|
1617 || iContext.iMessage.IsMessage<TCFPeer::TJoinRequest>(); |
|
1618 } |
|
1619 |
|
1620 DEFINE_SMELEMENT(TAwaitingCSRCreated, NetStateMachine::MState, CoreNetStates::TContext) |
|
1621 TBool CoreNetStates::TAwaitingCSRCreated::Accept() |
|
1622 { |
|
1623 return iContext.iMessage.IsMessage<TCFInternalEsock::TCSRCreated>(); |
|
1624 } |
|
1625 |
|
1626 EXPORT_DEFINE_SMELEMENT(TAwaitingDataClientStatusChange, NetStateMachine::MState, CoreNetStates::TContext) |
|
1627 EXPORT_C TBool CoreNetStates::TAwaitingDataClientStatusChange::Accept() |
|
1628 { |
|
1629 return iContext.iMessage.IsMessage<TCFControlProvider::TDataClientStatusChange>(); |
|
1630 } |
|
1631 |
|
1632 EXPORT_DEFINE_SMELEMENT(TAwaitingProviderStatusChangeOrDataClientStatusChange, NetStateMachine::MState, CoreNetStates::TContext) |
|
1633 EXPORT_C TBool CoreNetStates::TAwaitingProviderStatusChangeOrDataClientStatusChange::Accept() |
|
1634 { |
|
1635 return iContext.iMessage.IsMessage<TCFMcpr::TProviderStatusChange>() || iContext.iMessage.IsMessage<TCFControlProvider::TDataClientStatusChange>(); |
|
1636 } |
|
1637 |
|
1638 EXPORT_DEFINE_SMELEMENT(TAwaitingLegacyRMessage2Ext, NetStateMachine::MState, CoreNetStates::TContext) |
|
1639 EXPORT_C TBool CoreNetStates::TAwaitingLegacyRMessage2Ext::Accept() |
|
1640 { |
|
1641 return iContext.iMessage.IsTypeOf(Meta::STypeId::CreateSTypeId(TCFSigLegacyRMessage2Ext::EUid, TCFSigLegacyRMessage2Ext::ETypeId)); |
|
1642 } |
|
1643 |
|
1644 |
|
1645 EXPORT_DEFINE_SMELEMENT(TAwaitingRMessage2Processed, NetStateMachine::MState, CoreNetStates::TContext) |
|
1646 EXPORT_C TBool CoreNetStates::TAwaitingRMessage2Processed::Accept() |
|
1647 { |
|
1648 return iContext.iMessage.IsMessage<TCFLegacyMessage::TLegacyRMessage2Processed>(); |
|
1649 } |
|
1650 |
|
1651 EXPORT_C void CoreNetStates::TAwaitingRMessage2Processed::Cancel() |
|
1652 { |
|
1653 MeshMachine::CNodeParallelMessageStoreActivityBase* act = static_cast<MeshMachine::CNodeParallelMessageStoreActivityBase*>(iContext.Activity()); |
|
1654 |
|
1655 ASSERT(act->Message().IsTypeOf(Meta::STypeId::CreateSTypeId(TCFSigLegacyRMessage2Ext::EUid, TCFSigLegacyRMessage2Ext::ETypeId))); |
|
1656 static_cast<TCFSigLegacyRMessage2Ext&>(act->Message()).Cancel(iContext); |
|
1657 |
|
1658 act->SetError(KErrCancel); |
|
1659 } |
|
1660 |
|
1661 EXPORT_DEFINE_SMELEMENT(TAwaitingParamRequest, NetStateMachine::MState, PRStates::TContext) |
|
1662 EXPORT_C TBool TAwaitingParamRequest::Accept() |
|
1663 { |
|
1664 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
1665 if(iContext.iMessage.IsMessage<TCFScpr::TSetParamsRequest>() || iContext.iMessage.IsMessage<TCFScpr::TGetParamsRequest>()) |
|
1666 { |
|
1667 return ETrue; |
|
1668 } |
|
1669 #endif |
|
1670 return EFalse; |
|
1671 } |
|
1672 |
|
1673 EXPORT_DEFINE_SMELEMENT(TAwaitingApplyRequest, NetStateMachine::MState, PRStates::TContext) |
|
1674 EXPORT_C TBool TAwaitingApplyRequest::Accept() |
|
1675 { |
|
1676 return iContext.iMessage.IsMessage<TCFScpr::TApplyRequest>(); |
|
1677 } |
|
1678 |
|
1679 //-========================================================= |
|
1680 // |
|
1681 //State Forks |
|
1682 // |
|
1683 //-========================================================= |
|
1684 |
|
1685 EXPORT_DEFINE_SMELEMENT(TPeerPresent, NetStateMachine::MStateFork, CoreStates::TContext) |
|
1686 TInt TPeerPresent::TransitionTag() |
|
1687 { |
|
1688 return CoreStates::KPeerPresent | NetStateMachine::EForward; |
|
1689 } |
|
1690 |
|
1691 EXPORT_DEFINE_SMELEMENT(TNoTagOrNoPeer, NetStateMachine::MStateFork, CoreStates::TContext) |
|
1692 TInt TNoTagOrNoPeer::TransitionTag() |
|
1693 { |
|
1694 if (iContext.iPeer) |
|
1695 { |
|
1696 return MeshMachine::KNoTag | NetStateMachine::EForward; |
|
1697 } |
|
1698 return CoreStates::KNoPeer | NetStateMachine::EForward; |
|
1699 } |
|
1700 |
|
1701 EXPORT_DEFINE_SMELEMENT(TRetryOrIgnoreOrPropagate, NetStateMachine::MStateFork, CoreStates::TContext) |
|
1702 TInt TRetryOrIgnoreOrPropagate::TransitionTag() |
|
1703 { |
|
1704 TErrResponse& resp = message_cast<TEErrorRecovery::TErrorRecoveryResponse>(iContext.iMessage).iErrResponse; |
|
1705 if (resp.iAction == TErrResponse::EPropagate) |
|
1706 { |
|
1707 return CoreStates::KPropagate | NetStateMachine::EForward; |
|
1708 } |
|
1709 if (resp.iAction == TErrResponse::EIgnore) |
|
1710 { |
|
1711 return CoreStates::KIgnore | NetStateMachine::EForward; |
|
1712 } |
|
1713 return CoreStates::KRetry | NetStateMachine::EForward; |
|
1714 } |
|
1715 |
|
1716 // This transition tag follows the logic that any error is recoverable except for KErrCancel |
|
1717 // A KErrCancel error can come from either the activity or the current message if its a TError message |
|
1718 // A KErrCancel takes precedence over other errors |
|
1719 EXPORT_DEFINE_SMELEMENT(TNoTagOrRecoverableErrorTagOrErrorTag, NetStateMachine::MStateFork, CoreStates::TContext) |
|
1720 EXPORT_C TInt TNoTagOrRecoverableErrorTagOrErrorTag::TransitionTag() |
|
1721 { |
|
1722 TEBase::TError* msg = message_cast<TEBase::TError>(&iContext.iMessage); |
|
1723 if (KErrNone==iContext.iNodeActivity->Error() && NULL==msg) |
|
1724 { |
|
1725 // Not a TError message and no error present in the activity |
|
1726 return MeshMachine::KNoTag | NetStateMachine::EForward; |
|
1727 } |
|
1728 else if (iContext.iNodeActivity->Error() == KErrCancel || (msg && msg->iValue == KErrCancel)) |
|
1729 { |
|
1730 // Non recoverable KErrCancel |
|
1731 iContext.iNodeActivity->SetError(KErrCancel); |
|
1732 return KErrorTag | NetStateMachine::EForward; |
|
1733 } |
|
1734 else |
|
1735 { |
|
1736 // Any other error |
|
1737 if (msg) |
|
1738 { |
|
1739 // If the error came from the message then update the activity's error |
|
1740 iContext.iNodeActivity->SetError(msg->iValue); |
|
1741 } |
|
1742 return CoreStates::KRecoverableErrorTag | NetStateMachine::EForward; |
|
1743 } |
|
1744 } |
|
1745 |
|
1746 EXPORT_DEFINE_SMELEMENT(TBearerPresent, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1747 EXPORT_C TInt TBearerPresent::TransitionTag() |
|
1748 { |
|
1749 return CoreNetStates::KBearerPresent | NetStateMachine::EForward; |
|
1750 } |
|
1751 |
|
1752 EXPORT_DEFINE_SMELEMENT(TNoTagOrDataClientPresent, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1753 EXPORT_C TInt TNoTagOrDataClientPresent::TransitionTag() |
|
1754 { |
|
1755 if (iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData))) |
|
1756 { |
|
1757 return CoreNetStates::KDataClientPresent | NetStateMachine::EForward; |
|
1758 } |
|
1759 return KNoTag; |
|
1760 } |
|
1761 |
|
1762 EXPORT_DEFINE_SMELEMENT(TNoTagOrDataClientsToStop, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1763 EXPORT_C TInt TNoTagOrDataClientsToStop::TransitionTag() |
|
1764 { |
|
1765 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EStarted), |
|
1766 TClientType(0, TClientType::ELeaving))) |
|
1767 { |
|
1768 return CoreNetStates::KDataClientsToStop | NetStateMachine::EForward; |
|
1769 } |
|
1770 return KNoTag; |
|
1771 } |
|
1772 |
|
1773 EXPORT_DEFINE_SMELEMENT(TNoTagOrNoDataClientsToStop, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1774 TInt TNoTagOrNoDataClientsToStop::TransitionTag() |
|
1775 /** |
|
1776 Return: |
|
1777 KNoTag There are data clients present that are not marked EStopped |
|
1778 KNoDataClientsToStop There are no data clients present that are not marked EStopped |
|
1779 */ |
|
1780 { |
|
1781 if (iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EStarted))) |
|
1782 { |
|
1783 return KNoTag; |
|
1784 } |
|
1785 return CoreNetStates::KNoDataClientsToStop; |
|
1786 } |
|
1787 |
|
1788 EXPORT_DEFINE_SMELEMENT(TNoTagOnEvent, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1789 TInt TNoTagOnEvent::TransitionTag() |
|
1790 { |
|
1791 if (iContext.iNodeActivity) |
|
1792 { |
|
1793 iContext.iNodeActivity->RemoveOriginator(0); |
|
1794 } |
|
1795 return KNoTag; |
|
1796 } |
|
1797 |
|
1798 EXPORT_DEFINE_SMELEMENT(TNoTagOrNoDataClients, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1799 EXPORT_C TInt TNoTagOrNoDataClients::TransitionTag() |
|
1800 { |
|
1801 //If we have a started flow already, we should not be in here |
|
1802 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData))) |
|
1803 { |
|
1804 return MeshMachine::KNoTag | NetStateMachine::EForward; |
|
1805 } |
|
1806 return CoreNetStates::KNoDataClients | NetStateMachine::EForward; |
|
1807 } |
|
1808 |
|
1809 EXPORT_DEFINE_SMELEMENT(TNoTagOrBearerPresent, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1810 EXPORT_C TInt TNoTagOrBearerPresent::TransitionTag() |
|
1811 { |
|
1812 return iContext.Node().ServiceProvider()? CoreNetStates::KBearerPresent : MeshMachine::KNoTag; |
|
1813 } |
|
1814 |
|
1815 EXPORT_DEFINE_SMELEMENT(TNoTagOrBearerPresentOrErrorTag, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1816 TInt TNoTagOrBearerPresentOrErrorTag::TransitionTag() |
|
1817 { |
|
1818 TEBase::TError* msg = message_cast<TEBase::TError>(&iContext.iMessage); |
|
1819 if (KErrNone==iContext.iNodeActivity->Error() && NULL==msg) |
|
1820 { |
|
1821 CoreNetStates::TNoTagOrBearerPresent fork(iContext); |
|
1822 return fork.TransitionTag(); |
|
1823 } |
|
1824 if (msg) |
|
1825 { |
|
1826 iContext.iNodeActivity->SetError(msg->iValue); |
|
1827 } |
|
1828 return KErrorTag | NetStateMachine::EForward; |
|
1829 } |
|
1830 |
|
1831 EXPORT_DEFINE_SMELEMENT(TNoTagOrNoBearer, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1832 TInt TNoTagOrNoBearer::TransitionTag() |
|
1833 { |
|
1834 return iContext.Node().ServiceProvider()? MeshMachine::KNoTag : CoreNetStates::KNoBearer; |
|
1835 } |
|
1836 |
|
1837 EXPORT_DEFINE_SMELEMENT(TNoTagOrNonDefault, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1838 TInt TNoTagOrNonDefault::TransitionTag() |
|
1839 /** |
|
1840 Returns KNoTag uif sender is marked EDefault, else CoreNetStates::KNonDefault. |
|
1841 */ |
|
1842 { |
|
1843 __ASSERT_DEBUG(iContext.iPeer, User::Panic(KSpecAssert_ESockCrStaCPRSC, 29)); |
|
1844 return (iContext.iPeer->Flags() & TCFClientType::EDefault) ? KNoTag : CoreNetStates::KNonDefault; |
|
1845 } |
|
1846 |
|
1847 EXPORT_DEFINE_SMELEMENT(TNoTagOrNoClients, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1848 TInt TNoTagOrNoClients::TransitionTag() |
|
1849 /** |
|
1850 Returns KNoTag uif sender is marked EDefault, else CoreNetStates::KNonDefault. |
|
1851 */ |
|
1852 { |
|
1853 return iContext.Node().CountClients<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData | TCFClientType::ECtrl))? KNoTag : KNoClients; |
|
1854 } |
|
1855 |
|
1856 EXPORT_DEFINE_SMELEMENT(TNoTagBackwardsOrProviderStopped, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1857 EXPORT_C TInt TNoTagBackwardsOrProviderStopped::TransitionTag() |
|
1858 { |
|
1859 if (iContext.Node().GetFirstClient<TDefaultClientMatchPolicy>( |
|
1860 TClientType(TCFClientType::EData, TCFClientType::EStarted)) != NULL) |
|
1861 { |
|
1862 // At least one started data client |
|
1863 return MeshMachine::KNoTag | NetStateMachine::EBackward; |
|
1864 } |
|
1865 return CoreNetStates::KProviderStopped; |
|
1866 } |
|
1867 |
|
1868 EXPORT_DEFINE_SMELEMENT(TNoTagOrUnbindOnStop, NetStateMachine::MStateFork, CoreNetStates::TContext) |
|
1869 EXPORT_C TInt TNoTagOrUnbindOnStop::TransitionTag() |
|
1870 { |
|
1871 if (iContext.Node().ServiceProvider() && |
|
1872 !(iContext.Node().ServiceProvider()->Flags() & TCFClientType::EStarted) && |
|
1873 !(iContext.Node().ServiceProvider()->Flags() & TCFClientType::ELeaving) && |
|
1874 (iContext.Node().CountActivities(ECFActivityStart) == 0)) |
|
1875 { |
|
1876 return CoreNetStates::KUnbind; |
|
1877 } |
|
1878 return KNoTag; |
|
1879 } |
|
1880 |
|
1881 |
|
1882 //-========================================================= |
|
1883 // |
|
1884 //Transitions |
|
1885 // |
|
1886 //-========================================================= |
|
1887 |
|
1888 EXPORT_DEFINE_SMELEMENT(TForwardStateChange, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1889 EXPORT_C void TForwardStateChange::DoL() |
|
1890 { |
|
1891 //Forward to control clients if there are any |
|
1892 TInt ctrlClientCount = iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.iMessage, TClientType(TCFClientType::ECtrl)); |
|
1893 if (0==ctrlClientCount) |
|
1894 { //If there are no control clients any more, forward to the control provider |
|
1895 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.iMessage, TClientType(TCFClientType::ECtrlProvider)); |
|
1896 } |
|
1897 } |
|
1898 |
|
1899 |
|
1900 EXPORT_DEFINE_SMELEMENT(TStoreProvision, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1901 EXPORT_C void TStoreProvision::DoL() |
|
1902 { |
|
1903 TCFDataClient::TProvisionConfig& provisionMsg = message_cast<TCFDataClient::TProvisionConfig>(iContext.iMessage); |
|
1904 iContext.Node().iAccessPointConfig.Close(); |
|
1905 iContext.Node().iAccessPointConfig.Open(provisionMsg.iConfig); |
|
1906 } |
|
1907 |
|
1908 |
|
1909 EXPORT_DEFINE_SMELEMENT(TSendProvision, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1910 EXPORT_C void TSendProvision::DoL() |
|
1911 { |
|
1912 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
1913 |
|
1914 RNodeInterface* client = iContext.Node().FindClient(message_cast<TCFFactory::TPeerFoundOrCreated>(iContext.iMessage).iNodeId); |
|
1915 __ASSERT_ALWAYS(NULL != client && (client->Type() == TCFClientType::EData), CorePrPanic(KPanicIncorrectMessage)); |
|
1916 |
|
1917 // If the data client was stopped in between the completion of the join and before we send the provision |
|
1918 // message then the client will start leaving. This means we should not send the provision message since |
|
1919 // it is now redundant and it is not legal to send a message to a client which is leaving. |
|
1920 if(!(client->Flags() & TClientType::ELeaving)) |
|
1921 { |
|
1922 // The construction of the messagee will increase the ref count on the AccessPointConfig |
|
1923 // The reference will be released once the message has dispatched |
|
1924 client->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
1925 TCFDataClient::TProvisionConfig(iContext.Node().AccessPointConfig()).CRef()); |
|
1926 } |
|
1927 else |
|
1928 { |
|
1929 MESH_LOG((KCoreProviderStatesSubTag, _L8("TSendProvision:\tDoL - IGNORING POST!"))); |
|
1930 } |
|
1931 } |
|
1932 |
|
1933 EXPORT_DEFINE_SMELEMENT(TCreateDataClient, NetStateMachine::MStateTransition, PRStates::TContext) |
|
1934 |
|
1935 void TCreateDataClient::IssuePeerCreationRequestL(ESock::TCFServiceProvider::TCommsBinderRequest* aBinderRequestMessage /* = NULL */) |
|
1936 { |
|
1937 if (factoryobject_cast<CTierManagerBase>(&iContext.Node())) |
|
1938 { |
|
1939 RequestMetaConnPeer(iContext.Node().AccessPointConfig()); |
|
1940 } |
|
1941 else if (factoryobject_cast<CMetaConnectionProviderBase>(&iContext.Node())) |
|
1942 { |
|
1943 RequestConnPeer(iContext.Node().AccessPointConfig()); |
|
1944 } |
|
1945 else if (factoryobject_cast<CConnectionProviderBase>(&iContext.Node())) |
|
1946 { |
|
1947 RequestSubConnPeer(iContext.Node().AccessPointConfig(), aBinderRequestMessage); |
|
1948 } |
|
1949 else if (factoryobject_cast<CSubConnectionProviderBase>(&iContext.Node())) |
|
1950 { |
|
1951 RequestDataPeer(iContext.Node().AccessPointConfig(), aBinderRequestMessage); |
|
1952 } |
|
1953 else |
|
1954 { |
|
1955 User::Leave(KErrNotFound); |
|
1956 } |
|
1957 } |
|
1958 |
|
1959 void TCreateDataClient::RequestMetaConnPeer(const RMetaExtensionContainerC& aAccessPointCfg) |
|
1960 { |
|
1961 TAlwaysFindFactoryQuery query; |
|
1962 |
|
1963 const TLayerConfig* layerCfg = static_cast<const TLayerConfig*>(aAccessPointCfg.FindExtension( |
|
1964 STypeId::CreateSTypeId(TLayerConfig::EUid,TLayerConfig::ETypeId))); |
|
1965 __ASSERT_ALWAYS(layerCfg, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
1966 |
|
1967 TCFFactory::TFindOrCreatePeer msg(TCFPlayerRole::EMetaConnPlane, layerCfg->MCprUid(), &query); |
|
1968 |
|
1969 // Send the request to the central object broker |
|
1970 iContext.iNodeActivity->PostRequestTo(SockManGlobals::Get()->iCommsFactoryContainerBroker, msg, EFalse); |
|
1971 } |
|
1972 |
|
1973 void TCreateDataClient::RequestConnPeer (const RMetaExtensionContainerC& aAccessPointCfg) |
|
1974 { |
|
1975 TDefaultConnectionFactoryQuery query(iContext.Node().Id()); |
|
1976 |
|
1977 const TLayerConfig* layerCfg = static_cast<const TLayerConfig*>(aAccessPointCfg.FindExtension( |
|
1978 STypeId::CreateSTypeId(TLayerConfig::EUid,TLayerConfig::ETypeId))); |
|
1979 __ASSERT_ALWAYS(layerCfg, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
1980 |
|
1981 TCFFactory::TFindOrCreatePeer msg(TCFPlayerRole::EConnPlane, layerCfg->CprUid(), &query); |
|
1982 |
|
1983 // Send the request to the central object broker |
|
1984 iContext.iNodeActivity->PostRequestTo(SockManGlobals::Get()->iCommsFactoryContainerBroker, msg, EFalse); |
|
1985 } |
|
1986 |
|
1987 void TCreateDataClient::RequestSubConnPeer (const RMetaExtensionContainerC& aAccessPointCfg, ESock::TCFServiceProvider::TCommsBinderRequest* aBinderRequestMessage) |
|
1988 { |
|
1989 // The subconnection type carried in the binder request is only relevant when we are expected to create an SCPR |
|
1990 TSubConnOpen::TSubConnType scprType = TSubConnOpen::EAttachToDefault; |
|
1991 // If we have a protocol extension to apply then do so but default to nothing |
|
1992 |
|
1993 TUid factory = TUid::Null(); |
|
1994 if (aBinderRequestMessage) |
|
1995 { |
|
1996 scprType = (TSubConnOpen::TSubConnType)aBinderRequestMessage->iValue; |
|
1997 if (!aBinderRequestMessage->iFamilyBundle.IsNull()) |
|
1998 { |
|
1999 // Find the family we are interested in |
|
2000 RParameterFamily parameterFamily = aBinderRequestMessage->iFamilyBundle.FindFamily(KProtocolExtensionFamily); |
|
2001 |
|
2002 if(!parameterFamily.IsNull()) |
|
2003 { |
|
2004 STypeId typeId = STypeId::CreateSTypeId(CSubConnectionProtocolParameterSet::EUid, CSubConnectionProtocolParameterSet::EType); |
|
2005 CSubConnectionProtocolParameterSet* protocolParams = static_cast<CSubConnectionProtocolParameterSet*>(parameterFamily.FindParameterSet(typeId, RParameterFamily::ERequested)); |
|
2006 TProtocolExtensionSpecifier protocolSpecifier; |
|
2007 |
|
2008 const TLayerConfig* layerCfg = static_cast<const TLayerConfig*>(aAccessPointCfg.FindExtension( |
|
2009 STypeId::CreateSTypeId(TLayerConfig::EUid,TLayerConfig::ETypeId))); |
|
2010 __ASSERT_ALWAYS(layerCfg, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
2011 |
|
2012 if(protocolParams->FindAndRemoveExtension(protocolSpecifier, layerCfg->TierId()) == KErrNone) |
|
2013 { |
|
2014 // We have our protocol extension specifier |
|
2015 factory = protocolSpecifier.iSCPRFactoryUid; |
|
2016 } |
|
2017 } |
|
2018 } |
|
2019 } |
|
2020 // No special protocol extension SCPP given so revert to the default which is given in the access point config |
|
2021 if(factory == TUid::Null()) |
|
2022 { |
|
2023 const TLayerConfig* layerCfg = static_cast<const TLayerConfig*>(aAccessPointCfg.FindExtension( |
|
2024 STypeId::CreateSTypeId(TLayerConfig::EUid,TLayerConfig::ETypeId))); |
|
2025 __ASSERT_ALWAYS(layerCfg, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
2026 |
|
2027 factory = layerCfg->SCprUid(); |
|
2028 } |
|
2029 TDefaultSCPRFactoryQuery query (iContext.Node().Id(), scprType); |
|
2030 TCFFactory::TFindOrCreatePeer msg(TCFPlayerRole::ESubConnPlane, factory, &query); |
|
2031 // Send the request to the central object broker |
|
2032 iContext.iNodeActivity->PostRequestTo(SockManGlobals::Get()->iCommsFactoryContainerBroker, msg, EFalse); |
|
2033 } |
|
2034 |
|
2035 void TCreateDataClient::RequestDataPeer(const RMetaExtensionContainerC& aAccessPointCfg, ESock::TCFServiceProvider::TCommsBinderRequest* aBinderRequestMessage) |
|
2036 { |
|
2037 TNodeId controlProvider = iContext.Node().ControlProvider() ? iContext.Node().ControlProvider()->RecipientId() : TNodeId::NullId(); |
|
2038 TSubConnOpen::TSubConnType protocolType = TSubConnOpen::EAttachToDefault; |
|
2039 // Get the flow factory identity from our access point configuration |
|
2040 |
|
2041 const TLayerConfig* layerCfg = static_cast<const TLayerConfig*>(aAccessPointCfg.FindExtension( |
|
2042 STypeId::CreateSTypeId(TLayerConfig::EUid,TLayerConfig::ETypeId))); |
|
2043 __ASSERT_ALWAYS(layerCfg, CorePrPanic(KPanicUnexpectedExecutionPath)); |
|
2044 |
|
2045 TUid factory = layerCfg->ProtocolUid(); |
|
2046 |
|
2047 // Determine what protocol we want the flow factory to create |
|
2048 if(aBinderRequestMessage && ! aBinderRequestMessage->iFamilyBundle.IsNull()) |
|
2049 { |
|
2050 // Find the flow parameter family of parameters |
|
2051 RParameterFamily parameterFamily = aBinderRequestMessage->iFamilyBundle.FindFamily(KFlowParametersFamily); |
|
2052 |
|
2053 if(!parameterFamily.IsNull()) |
|
2054 { |
|
2055 STypeId typeId = STypeId::CreateSTypeId(CFlowRequestParameters::EUid, CFlowRequestParameters::EType); |
|
2056 CFlowRequestParameters* flowParams = static_cast<CFlowRequestParameters*>(parameterFamily.FindParameterSet(typeId, RParameterFamily::ERequested)); |
|
2057 |
|
2058 // The type of flow created by the flow factory is dependent only on the protocol type |
|
2059 protocolType = (TSubConnOpen::TSubConnType)flowParams->GetFlowParams().iProtocol; |
|
2060 } |
|
2061 } |
|
2062 TDefaultFlowFactoryQuery query(controlProvider, iContext.Node().Id(), iContext.iMessage.MessageId(), protocolType); |
|
2063 TCFFactory::TFindOrCreatePeer msg(TCFPlayerRole::EDataPlane, factory, &query); |
|
2064 // Send the request to the central object broker |
|
2065 iContext.iNodeActivity->PostRequestTo(SockManGlobals::Get()->iCommsFactoryContainerBroker, msg, EFalse); |
|
2066 } |
|
2067 |
|
2068 EXPORT_C void TCreateDataClient::DoL() |
|
2069 { |
|
2070 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
2071 TCFServiceProvider::TCommsBinderRequest* binderReq = message_cast<TCFServiceProvider::TCommsBinderRequest>(&iContext.iMessage); |
|
2072 |
|
2073 __ASSERT_DEBUG(binderReq, CorePrPanic(KPanicIncorrectMessage)); |
|
2074 |
|
2075 // Sender must be one of the control clients |
|
2076 // Except in the special case of a CPR being asked by one of its data clients (an SCPR) to stack another below it |
|
2077 __ASSERT_DEBUG( |
|
2078 iContext.iSender == iContext.NodeId() || |
|
2079 iContext.iPeer->Type() == TCFClientType::ECtrl || |
|
2080 ((iContext.iPeer->Type() == TCFClientType::EData) && (factoryobject_cast<CConnectionProviderBase>(&iContext.Node()) != NULL)), User::Panic(KSpecAssert_ESockCrStaCPRSC, 30)); |
|
2081 |
|
2082 IssuePeerCreationRequestL(binderReq); |
|
2083 |
|
2084 } |
|
2085 |
|
2086 EXPORT_DEFINE_SMELEMENT(TCancelDataClientStart, NetStateMachine::MStateTransition, PRStates::TContext) |
|
2087 EXPORT_C void TCancelDataClientStart::DoL() |
|
2088 { |
|
2089 // Cancel must come from the same activity that sent TStart |
|
2090 // This transition will handle Data Clients started by ECFActivityStart |
|
2091 // it will not handle those started by ECFActivityStartDataClient |
|
2092 RClientInterface::OpenPostMessageClose(TNodeCtxId(ECFActivityStart, iContext.NodeId()), iContext.NodeId(), TEBase::TCancel().CRef()); |
|
2093 } |
|
2094 |
|
2095 EXPORT_DEFINE_SMELEMENT(TProcessDataClientStop, NetStateMachine::MStateTransition, PRStates::TContext) |
|
2096 EXPORT_C void TProcessDataClientStop::DoL() |
|
2097 { |
|
2098 __ASSERT_DEBUG(iContext.iNodeActivity, CorePrPanic(KPanicNoActivity)); |
|
2099 |
|
2100 iContext.iNodeActivity->SetError(static_cast<TSigNumber&>(iContext.iMessage).iValue); |
|
2101 } |
|
2102 |
|
2103 DEFINE_SMELEMENT(TCancelAndCloseZone0ClientExtIfaces, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
2104 void TCancelAndCloseZone0ClientExtIfaces::DoL() |
|
2105 { |
|
2106 //0 means we will cancel and close all open extensions! |
|
2107 TCancelAndCloseAllClientExtItf msg(0); |
|
2108 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(iContext.NodeId(), msg, |
|
2109 TClientType(TCFClientType::EServProvider), TClientType(0, TCFClientType::ELeaving)); |
|
2110 } |
|
2111 |
|
2112 EXPORT_DEFINE_SMELEMENT(THandleDataClientStatusChange, NetStateMachine::MStateTransition, PRStates::TContext) |
|
2113 EXPORT_C void THandleDataClientStatusChange::DoL() |
|
2114 { |
|
2115 TCFControlProvider::TDataClientStatusChange& msg = message_cast<TCFControlProvider::TDataClientStatusChange>(iContext.iMessage); |
|
2116 |
|
2117 if(msg.iValue == TCFControlProvider::TDataClientStatusChange::EStarted) |
|
2118 { |
|
2119 iContext.iPeer->SetFlags(TCFClientType::EStarted); |
|
2120 |
|
2121 // One of my data clients is started, therefore, I am started |
|
2122 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
2123 msg, TClientType(TCFClientType::ECtrlProvider)); |
|
2124 } |
|
2125 else |
|
2126 { |
|
2127 iContext.iPeer->ClearFlags(TCFClientType::EStarted); |
|
2128 } |
|
2129 |
|
2130 } |
|
2131 |
|
2132 EXPORT_DEFINE_SMELEMENT(TSendDataClientStatusChangeStarted, NetStateMachine::MStateTransition, PRStates::TContext) |
|
2133 EXPORT_C void TSendDataClientStatusChangeStarted::DoL() |
|
2134 { |
|
2135 iContext.Node().PostToClients<TDefaultClientMatchPolicy>(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), |
|
2136 TCFControlProvider::TDataClientStatusChange(TCFControlProvider::TDataClientStatusChange::EStarted).CRef(), TClientType(TCFClientType::ECtrlProvider)); |
|
2137 } |
|
2138 |
|
2139 |
|
2140 EXPORT_DEFINE_SMELEMENT(TProcessOrForwardRMessage2Ext, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
2141 EXPORT_C void TProcessOrForwardRMessage2Ext::DoL() |
|
2142 { |
|
2143 ASSERT(iContext.iMessage.IsTypeOf(Meta::STypeId::CreateSTypeId(TCFSigLegacyRMessage2Ext::EUid, TCFSigLegacyRMessage2Ext::ETypeId))); |
|
2144 // static_cast as it will be a derivative and message_cast won't work |
|
2145 TCFSigLegacyRMessage2Ext& msg = static_cast<TCFSigLegacyRMessage2Ext&>(iContext.iMessage); |
|
2146 |
|
2147 if (msg.CanProcess(iContext)) |
|
2148 { |
|
2149 msg.ProcessL(iContext); |
|
2150 } |
|
2151 else |
|
2152 { |
|
2153 msg.ForwardL(iContext); |
|
2154 } |
|
2155 } |
|
2156 |
|
2157 EXPORT_DEFINE_SMELEMENT(TCancelStart, NetStateMachine::MStateTransition, CoreNetStates::TContext) |
|
2158 void TCancelStart::DoL() |
|
2159 { |
|
2160 CNodeActivityBase* startActivity = iContext.Node().FindActivityById(ECFActivityStart); |
|
2161 if (startActivity) |
|
2162 { |
|
2163 startActivity->Cancel(iContext); |
|
2164 } |
|
2165 } |
|
2166 |