|
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 // PPP MCpr |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 |
|
24 #include <comms-infras/ss_log.h> |
|
25 #include <comms-infras/agentmcpractivities.h> |
|
26 #include <comms-infras/coremcpractivities.h> |
|
27 #include <comms-infras/ss_tiermanagerutils.h> |
|
28 |
|
29 #include "pppmcpr.h" |
|
30 #include "pppmcprstates.h" |
|
31 #include "csdavailabilitylistener.h" |
|
32 |
|
33 #include <comms-infras/ss_msgintercept.h> |
|
34 |
|
35 using namespace Messages; |
|
36 using namespace MeshMachine; |
|
37 using namespace ESock; |
|
38 using namespace NetStateMachine; |
|
39 using namespace MCprActivities; |
|
40 |
|
41 #if defined __CFLOG_ACTIVE || defined SYMBIAN_TRACE_ENABLE |
|
42 #define KPppMCprTag KESockMetaConnectionTag |
|
43 _LIT8(KPppMCprSubTag, "PppMCpr"); |
|
44 #endif |
|
45 |
|
46 // No Bearer Activity |
|
47 namespace PppMCprNoBearerActivity |
|
48 { |
|
49 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, PppMCprNoBearer, TCFControlProvider::TNoBearer) |
|
50 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag) |
|
51 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer) |
|
52 NODEACTIVITY_END() |
|
53 } |
|
54 |
|
55 |
|
56 // Activity Map |
|
57 namespace PppMCprStates |
|
58 { |
|
59 DECLARE_DEFINE_ACTIVITY_MAP(stateMap) |
|
60 ACTIVITY_MAP_ENTRY(PppMCprNoBearerActivity, PppMCprNoBearer) |
|
61 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities) |
|
62 } // namespace PppMCprStates |
|
63 |
|
64 //-========================================================= |
|
65 // |
|
66 //CPppMetaConnectionProvider implementation |
|
67 // |
|
68 //-========================================================= |
|
69 |
|
70 CPppMetaConnectionProvider* CPppMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, |
|
71 const ESock::TProviderInfo& aProviderInfo) |
|
72 { |
|
73 // coverity[alloc_fn] coverity[alias] coverity[assign] |
|
74 CPppMetaConnectionProvider* self = new (ELeave) CPppMetaConnectionProvider(aFactory,aProviderInfo,PppMCprStates::stateMap::Self()); |
|
75 // coverity[push] |
|
76 CleanupStack::PushL(self); |
|
77 // coverity[alias] coverity[double_push] |
|
78 self->ConstructL(); |
|
79 CleanupStack::Pop(self); |
|
80 return self; |
|
81 } |
|
82 |
|
83 void CPppMetaConnectionProvider::ConstructL() |
|
84 { |
|
85 CAgentMetaConnectionProvider::ConstructL(); |
|
86 SetAccessPointConfigFromDbL(); |
|
87 } |
|
88 |
|
89 CPppMetaConnectionProvider::CPppMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, |
|
90 const ESock::TProviderInfo& aProviderInfo, |
|
91 const MeshMachine::TNodeActivityMap& aActivityMap) |
|
92 : CAgentMetaConnectionProvider(aFactory,aProviderInfo,aActivityMap) |
|
93 { |
|
94 LOG_NODE_CREATE(KPppMCprSubTag, CPppMetaConnectionProvider); |
|
95 } |
|
96 |
|
97 CPppMetaConnectionProvider::~CPppMetaConnectionProvider() |
|
98 { |
|
99 // Clean up the Agent Notification Handler |
|
100 SetAgentNotificationHandlerL(NULL); |
|
101 delete iAgentHandler; |
|
102 CPppMetaConnectionProvider::CancelAvailabilityMonitoring(); //Don't call virtual for obvious reasons! |
|
103 LOG_NODE_DESTROY(KPppMCprSubTag, CPppMetaConnectionProvider); |
|
104 } |
|
105 |
|
106 |
|
107 void CPppMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
108 { |
|
109 __CFLOG_VAR((KPppMCprTag, KPppMCprSubTag, _L8("CPppMetaConnectionProvider %08x:\tReceivedL() aCFMessage=%d"), |
|
110 this, aMessage.MessageId().MessageId())); |
|
111 |
|
112 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
113 |
|
114 TNodeContext<CPppMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
115 CCoreMetaConnectionProvider::Received(ctx); |
|
116 User::LeaveIfError(ctx.iReturn); |
|
117 } |
|
118 |
|
119 void CPppMetaConnectionProvider::CleanupCloseIapView(TAny* aThis) |
|
120 { |
|
121 reinterpret_cast<CPppMetaConnectionProvider*>(aThis)->CloseIapView(); |
|
122 } |
|
123 |
|
124 void CPppMetaConnectionProvider::SetAccessPointConfigFromDbL() |
|
125 { |
|
126 // Its necessary here to check whether the mcpr has already been provisioned, because it may be still |
|
127 // lingering because of a previous connection start |
|
128 if (AccessPointConfig().FindExtension(CBCAProvision::TypeId())) |
|
129 { |
|
130 ASSERT(AccessPointConfig().FindExtension(CIPConfig::TypeId())); |
|
131 ASSERT(AccessPointConfig().FindExtension(CPppLcpConfig::TypeId())); |
|
132 ASSERT(AccessPointConfig().FindExtension(CPppAuthConfig::TypeId())); |
|
133 ASSERT(AccessPointConfig().FindExtension(CPppTsyConfig::TypeId())); |
|
134 return; |
|
135 } |
|
136 |
|
137 RMetaExtensionContainer mec; |
|
138 mec.Open(AccessPointConfig()); |
|
139 CleanupClosePushL(mec); |
|
140 |
|
141 CCommsDatIapView* iapView = OpenIapViewLC(); |
|
142 |
|
143 // Presumptions: |
|
144 // - none of the extensions can already exist in the AccessPointConfig array. AppendExtensionL() |
|
145 // is presumed to panic if adding the same extension a second time. |
|
146 // - if we have added several extensions to the AccessPointConfig array before getting a failure |
|
147 // and leaving, it is presumed that the MCPr will be destroyed and AccessPointConfig destructor |
|
148 // will clean up the extensions immediately afterwards. |
|
149 mec.AppendExtensionL(CBCAProvision::NewLC(iapView)); |
|
150 CleanupStack::Pop(); //Ownership with the list |
|
151 |
|
152 mec.AppendExtensionL(CIPConfig::NewLC(iapView)); |
|
153 CleanupStack::Pop(); //Ownership with the list |
|
154 |
|
155 mec.AppendExtensionL(CPppLcpConfig::NewLC(iapView)); |
|
156 CleanupStack::Pop(); //Ownership with the list |
|
157 |
|
158 mec.AppendExtensionL(CPppAuthConfig::NewLC(iapView)); |
|
159 CleanupStack::Pop(); //Ownership with the list |
|
160 |
|
161 mec.AppendExtensionL(CPppTsyConfig::NewLC(iapView)); |
|
162 CleanupStack::Pop(); //Ownership with the list |
|
163 |
|
164 CleanupStack::PopAndDestroy(); // CloseIapView(); |
|
165 |
|
166 iAccessPointConfig.Close(); |
|
167 iAccessPointConfig.Open(mec); |
|
168 CleanupStack::PopAndDestroy(&mec); |
|
169 |
|
170 // Add the Agent Notification Handler. |
|
171 ASSERT(iAgentHandler == NULL); |
|
172 iAgentHandler = CPppAgentNotificationHandler::NewL(); // ownership retained |
|
173 SetAgentNotificationHandlerL(iAgentHandler); |
|
174 } |
|
175 |
|
176 void CPppMetaConnectionProvider::StartAvailabilityMonitoringL(const TNodeCtxId& aAvailabilityActivity) |
|
177 { |
|
178 ASSERT(iAvailabilityListener==NULL); //Only one start allowed from the av activity! |
|
179 const CPppTsyConfig& config = static_cast<const CPppTsyConfig&>(AccessPointConfig().FindExtensionL(STypeId::CreateSTypeId(CPppTsyConfig::EUid, CPppTsyConfig::ETypeId))); |
|
180 iAvailabilityListener = CCsdAvailabilityListener::NewL(aAvailabilityActivity, config, ProviderInfo().APId()); |
|
181 AddClientL(iAvailabilityListener->Id(), TClientType(TCFClientType::ERegistrar, TCFClientType::EAvailabilityProvider)); |
|
182 } |
|
183 |
|
184 void CPppMetaConnectionProvider::CancelAvailabilityMonitoring() |
|
185 { |
|
186 if (iAvailabilityListener) |
|
187 { |
|
188 RemoveClient(iAvailabilityListener->Id()); |
|
189 iAvailabilityListener = NULL; //iAvailabilityListener will delete itself when cancelled from the availability activity |
|
190 } |
|
191 } |
|
192 |
|
193 CPppAgentNotificationHandler* CPppAgentNotificationHandler::NewL () |
|
194 { |
|
195 return new (ELeave)CPppAgentNotificationHandler(); |
|
196 } |
|
197 |
|
198 |
|
199 CPppAgentNotificationHandler::CPppAgentNotificationHandler() |
|
200 { |
|
201 } |
|
202 |
|
203 |
|
204 /** |
|
205 Upcall from the Agent |
|
206 */ |
|
207 void CPppAgentNotificationHandler::ConnectCompleteL() |
|
208 { |
|
209 TBool pop = EFalse; |
|
210 CPppProvisionInfo* pppInfo = const_cast<CPppProvisionInfo*>(static_cast<const CPppProvisionInfo*>(GetExtension(STypeId::CreateSTypeId(CPppProvisionInfo::EUid, CPppProvisionInfo::ETypeId)))); |
|
211 if (!pppInfo) // not provisioned yet |
|
212 { |
|
213 pppInfo = new (ELeave) CPppProvisionInfo; |
|
214 CleanupStack::PushL(pppInfo); |
|
215 pop = ETrue; |
|
216 } |
|
217 |
|
218 const TInt KMaxExcessData = 1503 * 2; // from PPP HDLC |
|
219 RBuf8 excessData; |
|
220 CleanupClosePushL(excessData); |
|
221 excessData.CreateL(KMaxExcessData); |
|
222 |
|
223 (void)ReadExcessData(excessData); |
|
224 User::LeaveIfError(pppInfo->SetExcessData(excessData)); |
|
225 |
|
226 CleanupStack::PopAndDestroy(&excessData); |
|
227 |
|
228 pppInfo->SetIsDialIn(QueryIsDialIn()); |
|
229 |
|
230 if (pop) |
|
231 { |
|
232 AppendExtensionL(pppInfo); |
|
233 CleanupStack::Pop(pppInfo); |
|
234 } |
|
235 } |