|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // IP Connection Provider activity definitions specific to User Prompt Service (UPS). |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #define SYMBIAN_NETWORKING_UPS |
|
24 |
|
25 #ifdef SYMBIAN_NETWORKING_UPS |
|
26 |
|
27 #include "ipcprups_activities.h" |
|
28 #include <comms-infras/upsprstates.h> |
|
29 #include <comms-infras/upsmessages.h> |
|
30 #include <comms-infras/corecpractivities.h> |
|
31 #include "ipcprups_states.h" |
|
32 |
|
33 using namespace MeshMachine; |
|
34 using namespace Messages; |
|
35 using namespace UpsCprActivities; |
|
36 using namespace ESock; |
|
37 using namespace NetStateMachine; |
|
38 using namespace IpCprActivities; |
|
39 using namespace CprClientLeaveActivity; |
|
40 |
|
41 namespace IpCprActivities |
|
42 { |
|
43 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityClientJoin, IpCprControlClientJoin, TNodeSignal::TNullMessageId, CIpCprCtrlClientJoinActivity::NewL) //May be waiting for both messages |
|
44 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingControlClientJoin, IpCprStates::TNoTagOrUpsQueryOrAttachCapabilityQuery) |
|
45 |
|
46 // Non-UPS path |
|
47 THROUGH_NODEACTIVITY_ENTRY(IpCprStates::KAttachCapabilityQuery, IpCprStates::TCheckAttachCapabilities, TNoTag) |
|
48 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TAddControlClientAndSendJoinCompleteIfRequest, TNoTag) |
|
49 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendDataClientActive) |
|
50 |
|
51 // UPS path. Here if message was TCtrlClientJoinRequest and UPS Access Point Config extension was found. |
|
52 THROUGH_NODEACTIVITY_ENTRY(IpCprStates::KUpsQuery, CDeferredCtrlClientJoinActivity::TStoreControlClient, TNoTag) |
|
53 NODEACTIVITY_ENTRY(KNoTag, CIpCprCtrlClientJoinActivity::TSendPolicyCheckRequest, |
|
54 UpsStates::TAwaitingPolicyCheckResponse, CIpCprCtrlClientJoinActivity::TNoTagOrUpsErrorTag) |
|
55 // UPS success. A TPolicyCheckResponse was received with authorisation granted. |
|
56 LAST_NODEACTIVITY_ENTRY(KNoTag, CDeferredCtrlClientJoinActivity::TAddControlClientAndSendJoinComplete) |
|
57 |
|
58 // UPS error. A TPolicyCheckResponse was received with authorisation denied. |
|
59 LAST_NODEACTIVITY_ENTRY(CIpCprCtrlClientJoinActivity::KUpsErrorTag, TDoNothing) |
|
60 NODEACTIVITY_END() |
|
61 |
|
62 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityPolicyCheckRequest, IpCprPolicyCheckRequest, UpsMessage::TPolicyCheckRequest, CNodeParallelActivityBase::NewL) |
|
63 // TODO: decide whether we should move some of these transitions/forks to the UpsCoreProviders |
|
64 FIRST_NODEACTIVITY_ENTRY(UpsStates::TAwaitingPolicyCheckRequest, IpCprStates::TNoTagOrUpsDisabledOrUpsEnabled) |
|
65 LAST_NODEACTIVITY_ENTRY(IpCprStates::KUpsDisabled, IpCprStates::TPostDisabledPolicyCheckResponseToOriginators) |
|
66 |
|
67 THROUGH_NODEACTIVITY_ENTRY(IpCprStates::KUpsEnabled, IpCprStates::TPopulatePolicyCheckRequest, TNoTag) |
|
68 NODEACTIVITY_ENTRY(KNoTag, UpsStates::TPostToControlProvider, UpsStates::TAwaitingPolicyCheckResponse, TNoTagOrErrorTag) |
|
69 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreStates::TPostToOriginators) |
|
70 LAST_NODEACTIVITY_ENTRY(KErrorTag, TDoNothing) |
|
71 NODEACTIVITY_END() |
|
72 |
|
73 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityClientLeave, IpCprClientLeave, TNodeSignal::TNullMessageId, CClientLeaveActivity::NewL) |
|
74 FIRST_NODEACTIVITY_ENTRY(CoreStates::TAwaitingClientLeave, MeshMachine::TNoTag) |
|
75 THROUGH_NODEACTIVITY_ENTRY(KNoTag, IpCprStates::TSendUpsStatusChange, MeshMachine::TNoTag) |
|
76 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CClientLeaveActivity::TRemoveClientAndDestroyOrphanedDataClients, CClientLeaveActivity::TNoTagOrSendPriorityToCtrlProvider) |
|
77 NODEACTIVITY_ENTRY(CprStates::KSendPriorityToCtrlProvider, CClientLeaveActivity::TUpdatePriorityForControlProvider, CoreStates::TAwaitingJoinComplete, CClientLeaveActivity::TNoTagOrSendPriorityToServProvider) |
|
78 NODEACTIVITY_ENTRY(CprStates::KSendPriorityToServProvider, CClientLeaveActivity::TUpdatePriorityForServiceProviders, CoreStates::TAwaitingJoinComplete, MeshMachine::TNoTag) |
|
79 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CClientLeaveActivity::TSendLeaveCompleteAndSendDataClientIdleIfNeeded, MeshMachine::TNoTag) |
|
80 LAST_NODEACTIVITY_ENTRY(KNoTag, CprStates::TSendDataClientStatusStoppedIfNoControlClient) |
|
81 NODEACTIVITY_END() |
|
82 } |
|
83 |
|
84 // |
|
85 // CIpCprCtrlClientJoinActivity |
|
86 // |
|
87 |
|
88 MeshMachine::CNodeActivityBase* CIpCprCtrlClientJoinActivity::NewL(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode) |
|
89 { |
|
90 TUint c = GetNextActivityCountL(aActivitySig, aNode); |
|
91 |
|
92 return new (ELeave) CIpCprCtrlClientJoinActivity(aActivitySig, aNode, c); |
|
93 } |
|
94 |
|
95 CIpCprCtrlClientJoinActivity::CIpCprCtrlClientJoinActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode, TUint aNextActivityCount) |
|
96 : CIpCprUpsCtrlClientJoinActivity(aActivitySig, aNode, aNextActivityCount) |
|
97 { |
|
98 } |
|
99 |
|
100 void CIpCprCtrlClientJoinActivity::GetPlatSecResultAndDestinationL(const ESock::MPlatsecApiExt& aPlatSecApi, TInt& aPlatSecResult, TUpsDestinationAddrType& aDestinationType, TDes8& aDestination) const |
|
101 { |
|
102 aPlatSecResult = IpCprStates::CheckAttachPolicy(aPlatSecApi); |
|
103 aDestination = KNullDesC8(); |
|
104 aDestinationType = ETNone; |
|
105 } |
|
106 |
|
107 // |
|
108 // CIpCprUpsCtrlClientJoinActivity |
|
109 // |
|
110 |
|
111 CIpCprUpsCtrlClientJoinActivity::CIpCprUpsCtrlClientJoinActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode, TUint aNextActivityCount) |
|
112 : CDeferredCtrlClientJoinActivity(aActivitySig, aNode, aNextActivityCount) |
|
113 { |
|
114 } |
|
115 |
|
116 DEFINE_SMELEMENT(CIpCprUpsCtrlClientJoinActivity::TSendPolicyCheckRequest, NetStateMachine::MStateTransition, CIpCprUpsCtrlClientJoinActivity::TContext) |
|
117 |
|
118 void CIpCprUpsCtrlClientJoinActivity::TSendPolicyCheckRequest::DoL() |
|
119 /** |
|
120 This transition is IPCPR specific because it applies the platsec check against NetworkServices, |
|
121 and the TUpsDestinationAddr happens to be null for IP, but may not be for other technologies. |
|
122 |
|
123 @TODO PREQ1116 - could we provision the technology specific information in a new APC structure, |
|
124 as Viki suggests, and make this generic code ? How would this be done ? Can we template the code |
|
125 against capability ? |
|
126 */ |
|
127 { |
|
128 // Send TPolicyCheckRequest |
|
129 |
|
130 const MPlatsecApiExt* const platSecApi = reinterpret_cast<const MPlatsecApiExt*>(address_cast<TNodeId>(iContext.iSender).Node().FetchNodeInterfaceL(MPlatsecApiExt::KInterfaceId)); |
|
131 |
|
132 // Retrieve process id and thread id |
|
133 TProcessId processId; |
|
134 TThreadId threadId; |
|
135 User::LeaveIfError(platSecApi->GetProcessAndThreadId(processId, threadId)); |
|
136 |
|
137 TInt policyCheckResult = KErrCorrupt; // sanity - ensure it is overwritten |
|
138 TUpsDestinationAddr destination; |
|
139 TUpsDestinationAddrType destinationType; |
|
140 |
|
141 CIpCprUpsCtrlClientJoinActivity* act = iContext.Activity(); |
|
142 |
|
143 act->GetPlatSecResultAndDestinationL(*platSecApi, policyCheckResult, destinationType, destination); |
|
144 |
|
145 // Retrieve policy check result |
|
146 const CMMCommsProviderBase& node = iContext.Node(); |
|
147 // Create a TPolicyCheckRequest message (with an empty destination name) and send to Control Provider. |
|
148 const TPolicyCheckRequestParams params(processId, threadId, policyCheckResult, destination, destinationType); |
|
149 const UpsMessage::TPolicyCheckRequest checkMsg(params); |
|
150 |
|
151 RNodeInterface* const ctrlProvider = node.ControlProvider(); |
|
152 ASSERT(ctrlProvider); |
|
153 act->PostRequestTo(*ctrlProvider, checkMsg); |
|
154 } |
|
155 |
|
156 DEFINE_SMELEMENT(CIpCprUpsCtrlClientJoinActivity::TNoTagOrUpsErrorTag, NetStateMachine::MStateFork, CIpCprCtrlClientJoinActivity::TContext) |
|
157 |
|
158 TInt CIpCprUpsCtrlClientJoinActivity::TNoTagOrUpsErrorTag::TransitionTag() |
|
159 /** |
|
160 Return KNoTag if UPS was successful, else KUpsErrorTag. |
|
161 |
|
162 Also sets the activity error which triggers cleanup in ~CReversibleCtrlClientJoinActivity. |
|
163 |
|
164 @return KNoTag if a TPolicyCheckResponse was received with KErrNone, KErrorTag if a |
|
165 TPolicyCheckResponse was received without KErrNone, KErrorTag if TError was received. |
|
166 |
|
167 @TODO PREQ1116 - this is generic enough to be moved into CReversibleCtrlClientJoinActivity at least. |
|
168 */ |
|
169 { |
|
170 const TEBase::TError* const errMsg = message_cast<TEBase::TError>(&iContext.iMessage); |
|
171 CNodeActivityBase* act = iContext.Activity(); |
|
172 if (errMsg) |
|
173 { |
|
174 act->SetError(errMsg->iValue); |
|
175 return KUpsErrorTag; |
|
176 } |
|
177 |
|
178 const UpsMessage::TPolicyCheckResponse& msg = message_cast<UpsMessage::TPolicyCheckResponse>(iContext.iMessage); |
|
179 |
|
180 if (msg.iValue != KErrNone) |
|
181 { |
|
182 act->SetError(msg.iValue); |
|
183 return KUpsErrorTag; |
|
184 } |
|
185 return KNoTag; |
|
186 } |
|
187 |
|
188 #endif //SYMBIAN_NETWORKING_UPS |