|
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 // Pdp MCPR |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <comms-infras/ss_log.h> |
|
24 #include "pdpmcpr.h" |
|
25 #include "pdpmcprstates.h" |
|
26 #include "PDPProvision.h" |
|
27 #include "psdavailabilitylistener.h" |
|
28 #include <comms-infras/agentmcpractivities.h> |
|
29 #include <comms-infras/coremcpractivities.h> |
|
30 #include <comms-infras/ss_msgintercept.h> |
|
31 #include <elements/nm_messages_errorrecovery.h> |
|
32 |
|
33 using namespace Messages; |
|
34 using namespace MeshMachine; |
|
35 using namespace ESock; |
|
36 using namespace NetStateMachine; |
|
37 using namespace MCprActivities; |
|
38 |
|
39 |
|
40 // No Bearer Activity |
|
41 namespace PdpMCPRNoBearerActivity |
|
42 { |
|
43 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, activity, TCFControlProvider::TNoBearer) |
|
44 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag) |
|
45 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer) |
|
46 NODEACTIVITY_END() |
|
47 } |
|
48 |
|
49 namespace PdpMCprErrorRecoveryActivity |
|
50 { |
|
51 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityErrorRecovery, PdpMCprErrorRecovery, TEErrorRecovery::TErrorRecoveryRequest, CPdpErrorRecoveryActivity::NewL) |
|
52 FIRST_NODEACTIVITY_ENTRY(MCprStates::TAwaitingErrorRecoveryRequest, MeshMachine::TNoTag) |
|
53 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CPdpErrorRecoveryActivity::TProcessErrorRecoveryReq, CPdpErrorRecoveryActivity::TPdpContentionNoTagOrError) |
|
54 NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing, CPdpErrorRecoveryActivity::TAwaitingContentionResult, MeshMachine::TNoTag) |
|
55 LAST_NODEACTIVITY_ENTRY(KNoTag, CPdpErrorRecoveryActivity::TProcessContentionResult) |
|
56 LAST_NODEACTIVITY_ENTRY(KErrorTag, MeshMachine::TDoNothing) |
|
57 NODEACTIVITY_END() |
|
58 } |
|
59 |
|
60 // Activity Map |
|
61 namespace PdpMCprStates |
|
62 { |
|
63 DECLARE_DEFINE_ACTIVITY_MAP(stateMap) |
|
64 ACTIVITY_MAP_ENTRY(PdpMCPRNoBearerActivity, activity) |
|
65 ACTIVITY_MAP_ENTRY(PdpMCprErrorRecoveryActivity, PdpMCprErrorRecovery) |
|
66 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities) |
|
67 } // namespace PdpMCprStates |
|
68 |
|
69 namespace PdpMCprErrorRecoveryActivity |
|
70 { |
|
71 CNodeActivityBase* CPdpErrorRecoveryActivity::NewL( const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode ) |
|
72 { |
|
73 TUint c = GetNextActivityCountL(aActivitySig,aNode); |
|
74 return new(ELeave)CPdpErrorRecoveryActivity(aActivitySig, aNode, c); |
|
75 } |
|
76 |
|
77 CPdpErrorRecoveryActivity::CPdpErrorRecoveryActivity(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode, TUint aActivitiesCount) |
|
78 : MeshMachine::CNodeParallelActivityBase(aActivitySig, aNode, aActivitiesCount) |
|
79 { |
|
80 } |
|
81 |
|
82 CPdpErrorRecoveryActivity::~CPdpErrorRecoveryActivity() |
|
83 { |
|
84 } |
|
85 } |
|
86 |
|
87 //-========================================================= |
|
88 // |
|
89 //CPdpMetaConnectionProvider implementation |
|
90 // |
|
91 //-========================================================= |
|
92 |
|
93 CPdpMetaConnectionProvider* CPdpMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, const TProviderInfo& aProviderInfo) |
|
94 { |
|
95 // coverity[alloc_fn] coverity[alias] coverity[assign] |
|
96 CPdpMetaConnectionProvider* provider = new (ELeave) CPdpMetaConnectionProvider(aFactory, aProviderInfo); |
|
97 // coverity[push] |
|
98 CleanupStack::PushL(provider); |
|
99 // coverity[alias] coverity[double_push] |
|
100 provider->ConstructL(); |
|
101 CleanupStack::Pop(provider); |
|
102 return provider; |
|
103 } |
|
104 |
|
105 void CPdpMetaConnectionProvider::ConstructL() |
|
106 { |
|
107 CAgentMetaConnectionProvider::ConstructL(); |
|
108 SetAccessPointConfigFromDbL(); |
|
109 } |
|
110 |
|
111 CPdpMetaConnectionProvider::CPdpMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, const TProviderInfo& aProviderInfo) |
|
112 : CAgentMetaConnectionProvider(aFactory, aProviderInfo, PdpMCprStates::stateMap::Self()) |
|
113 { |
|
114 LOG_NODE_CREATE(KPdpMCprSubTag, CPdpMetaConnectionProvider); |
|
115 } |
|
116 |
|
117 CPdpMetaConnectionProvider::~CPdpMetaConnectionProvider() |
|
118 { |
|
119 CPdpMetaConnectionProvider::CancelAvailabilityMonitoring(); //Don't call virtual for obvious reasons! |
|
120 LOG_NODE_DESTROY(KPdpMCprSubTag, CPdpMetaConnectionProvider); |
|
121 } |
|
122 |
|
123 void CPdpMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
124 { |
|
125 __CFLOG_VAR((KPdpMCprTag, KPdpMCprSubTag, _L8("CPdpMetaConnectionProvider [this=%08x]::ReceivedL() aMessage=%d"), |
|
126 this, aMessage.MessageId().MessageId())); |
|
127 |
|
128 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
129 |
|
130 TNodeContext<CPdpMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
131 CCoreMetaConnectionProvider::Received(ctx); |
|
132 User::LeaveIfError(ctx.iReturn); |
|
133 } |
|
134 |
|
135 void CPdpMetaConnectionProvider::SetAccessPointConfigFromDbL() |
|
136 { |
|
137 RMetaExtensionContainer mec; |
|
138 mec.Open(AccessPointConfig()); |
|
139 CleanupClosePushL(mec); |
|
140 |
|
141 CCommsDatIapView* iapView = OpenIapViewLC(); |
|
142 |
|
143 mec.AppendExtensionL(CIPConfig::NewFromGPRSOutLC(iapView)); |
|
144 CleanupStack::Pop(); |
|
145 mec.AppendExtensionL(CBCAProvision::NewLC(iapView)); |
|
146 CleanupStack::Pop(); |
|
147 mec.AppendExtensionL(CTSYProvision::NewLC(iapView)); |
|
148 CleanupStack::Pop(); |
|
149 mec.AppendExtensionL(CImsExtProvision::NewLC(iapView)); |
|
150 CleanupStack::Pop(); |
|
151 |
|
152 CGPRSProvision* gprsProvision = CGPRSProvision::NewLC(iapView); |
|
153 mec.AppendExtensionL(gprsProvision); |
|
154 CleanupStack::Pop(gprsProvision); |
|
155 |
|
156 //It's legal for the qos defaults to be absent. |
|
157 //in this case they're going to be supplied by |
|
158 //GuQoS. |
|
159 CDefaultPacketQoSProvision* defaultQoS = NULL; |
|
160 TRAP_IGNORE(defaultQoS = CDefaultPacketQoSProvision::NewL(iapView)); |
|
161 if (defaultQoS) |
|
162 { |
|
163 CleanupStack::PushL(defaultQoS); |
|
164 mec.AppendExtensionL(defaultQoS); |
|
165 CleanupStack::Pop(defaultQoS); |
|
166 } |
|
167 |
|
168 CRawIpAgentConfig* rawIpAgentConfig = CRawIpAgentConfig::NewLC(iapView, &gprsProvision->GetScratchContextAs<TPacketDataConfigBase>()); |
|
169 mec.AppendExtensionL(rawIpAgentConfig); |
|
170 CleanupStack::Pop(); |
|
171 |
|
172 mec.AppendExtensionL(CPppLcpConfig::NewLC(iapView)); |
|
173 CleanupStack::Pop(); |
|
174 mec.AppendExtensionL(CPppAuthConfig::NewLC(iapView)); |
|
175 CleanupStack::Pop(); |
|
176 |
|
177 CPppProvisionInfo* agentProvision = new (ELeave) CPppProvisionInfo; |
|
178 CleanupStack::PushL(agentProvision); |
|
179 agentProvision->SetIsDialIn(KErrNotSupported); |
|
180 agentProvision->SetNotificationData(NULL); |
|
181 mec.AppendExtensionL(agentProvision); |
|
182 CleanupStack::Pop(agentProvision); |
|
183 |
|
184 CleanupStack::PopAndDestroy(); // CloseIapView(); |
|
185 |
|
186 iAccessPointConfig.Close(); |
|
187 iAccessPointConfig.Open(mec); |
|
188 CleanupStack::PopAndDestroy(&mec); |
|
189 } |
|
190 |
|
191 void CPdpMetaConnectionProvider::StartAvailabilityMonitoringL(const TNodeCtxId& aAvailabilityActivity) |
|
192 { |
|
193 ASSERT(iAvailabilityListener==NULL); //Only one start allowed from the av activity! |
|
194 const CTSYProvision& config = static_cast<const CTSYProvision&>(AccessPointConfig().FindExtensionL(STypeId::CreateSTypeId(CTSYProvision::EUid, CTSYProvision::ETypeId))); |
|
195 iAvailabilityListener = CPsdAvailabilityListener::NewL(aAvailabilityActivity, config, ProviderInfo().APId(), GetTierManager()->IsUnavailableDueToContention(this)); |
|
196 AddClientL(iAvailabilityListener->Id(), TClientType(TCFClientType::ERegistrar, TCFClientType::EAvailabilityProvider)); |
|
197 } |
|
198 |
|
199 void CPdpMetaConnectionProvider::CancelAvailabilityMonitoring() |
|
200 { |
|
201 if (iAvailabilityListener) |
|
202 { |
|
203 RemoveClient(iAvailabilityListener->Id()); |
|
204 iAvailabilityListener = NULL; //iAvailabilityListener will delete itself when cancelled from the availability activity |
|
205 } |
|
206 } |
|
207 |
|
208 void CPdpMetaConnectionProvider::ContentionOccured() |
|
209 { |
|
210 // Send a stop request to the stop activity. |
|
211 TInt stopCode = KErrConnectionContention; |
|
212 RClientInterface::OpenPostMessageClose(NodeId(), NodeId(), TCFDataClient::TStop(stopCode).CRef()); |
|
213 } |
|
214 |
|
215 void CPdpMetaConnectionProvider::ContentionResolved(const Messages::TNodeId& aPendingCprId, TBool aResult) |
|
216 { |
|
217 TPdpContentionMessages::TPdpContentionResultMessage msg(aPendingCprId, aResult); |
|
218 TRAP_IGNORE(ReceivedL(TNodeId(Id()), TNodeId(Id()), msg)); |
|
219 } |
|
220 |
|
221 void CPdpMetaConnectionProvider::ReportContentionAvailabilityStatus(const TAvailabilityStatus& aAvailabilityStatus) const |
|
222 { |
|
223 if (iAvailabilityListener) |
|
224 { |
|
225 iAvailabilityListener->ReportContentionAvailabilityStatusIfRequired(aAvailabilityStatus); |
|
226 } |
|
227 } |
|
228 |