|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: S60 MCPR implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file s60mcpr.cpp |
|
21 S60 MCPR implementation |
|
22 */ |
|
23 |
|
24 #include <comms-infras/ss_msgintercept.h> |
|
25 |
|
26 #include "s60mcpr.h" |
|
27 #include "s60mcprstates.h" |
|
28 #include "s60mcpractivities.h" |
|
29 |
|
30 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
31 |
|
32 #include <comms-infras/ss_protopt.h> |
|
33 #include "s60tcprecvwin.h" |
|
34 |
|
35 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
36 |
|
37 using namespace Messages; |
|
38 using namespace MeshMachine; |
|
39 using namespace ESock; |
|
40 using namespace MCprActivities; |
|
41 |
|
42 // ======== MEMBER FUNCTIONS ======== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CS60MetaConnectionProvider::NewL |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CS60MetaConnectionProvider* CS60MetaConnectionProvider::NewL( CMetaConnectionProviderFactoryBase& aFactory, |
|
49 const TProviderInfo& aProviderInfo ) |
|
50 { |
|
51 S60MCPRLOGSTRING("S60MCPR::NewL()"); |
|
52 |
|
53 CS60MetaConnectionProvider* self = |
|
54 new (ELeave) CS60MetaConnectionProvider( aFactory, |
|
55 aProviderInfo, |
|
56 S60MCprActivities::S60MCprActivityMap::Self()); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CS60MetaConnectionProvider::CS60MetaConnectionProvider |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CS60MetaConnectionProvider::CS60MetaConnectionProvider( CMetaConnectionProviderFactoryBase& aFactory, |
|
68 const TProviderInfo& aProviderInfo, |
|
69 const MeshMachine::TNodeActivityMap& aActivityMap ) |
|
70 : CMobilityMetaConnectionProvider( aFactory, aProviderInfo, aActivityMap ), |
|
71 iDataClientStatusStarted( EFalse ) |
|
72 { |
|
73 LOG_NODE_CREATE(KS60MCprTag, CS60MetaConnectionProvider); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CS60MetaConnectionProvider::ConstructL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CS60MetaConnectionProvider::ConstructL() |
|
81 { |
|
82 CCoreMetaConnectionProvider::ConstructL(); |
|
83 iPolicy = CMPMPolicyRequests::NewL( *(MMPMPolicyNotificationUser*)this ); |
|
84 S60MCPRLOGSTRING2("S60MCPR<%x>::ConstructL() iPolicy=%x",(TInt*)this, (TInt*)iPolicy); |
|
85 |
|
86 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
87 |
|
88 RMetaExtensionContainer mec; |
|
89 mec.Open(iAccessPointConfig); |
|
90 CleanupClosePushL(mec); |
|
91 |
|
92 //Append pointer to lookup table which holds the various TCP receive window sizes for different bearer types. |
|
93 CTCPReceiveWindowSize* receiveWindow; |
|
94 receiveWindow = new (ELeave)CS60TCPReceiveWindowSize(); |
|
95 |
|
96 CleanupStack::PushL(receiveWindow); |
|
97 mec.AppendExtensionL(receiveWindow); |
|
98 CleanupStack::Pop(receiveWindow); |
|
99 |
|
100 //Append the pointer of CSAPSetOpt which provides generic SetOpt( ) implementation |
|
101 CSAPSetOpt* protoOption = new (ELeave)CSAPSetOpt(); |
|
102 CleanupStack::PushL(protoOption); |
|
103 mec.AppendExtensionL(protoOption); |
|
104 CleanupStack::Pop(protoOption); |
|
105 |
|
106 iAccessPointConfig.Close(); |
|
107 iAccessPointConfig.Open(mec); |
|
108 CleanupStack::PopAndDestroy(&mec); |
|
109 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CS60MetaConnectionProvider::~CS60MetaConnectionProvider |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CS60MetaConnectionProvider::~CS60MetaConnectionProvider() |
|
117 { |
|
118 if ( iPolicy ) |
|
119 { |
|
120 iPolicy->RequestDelete(); |
|
121 } |
|
122 S60MCPRLOGSTRING1("S60MCPR<%x>::~CS60MetaConnectionProvider",(TInt*)this); |
|
123 LOG_NODE_DESTROY(KS60MCprTag, CS60MetaConnectionProvider); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CS60MetaConnectionProvider::ReceivedL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CS60MetaConnectionProvider::ReceivedL( const TRuntimeCtxId& aSender, |
|
131 const TNodeId& aRecipient, |
|
132 TSignatureBase& aMessage ) |
|
133 { |
|
134 S60MCPRLOGSTRING2("S60MCPR<%x>::ReceivedL() aMessage=%d",(TInt*)this, aMessage.MessageId().MessageId()); |
|
135 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
136 |
|
137 TNodeContext<CS60MetaConnectionProvider> ctx( *this, aMessage, aSender, aRecipient ); |
|
138 CMobilityMetaConnectionProvider::Received( ctx ); |
|
139 User::LeaveIfError( ctx.iReturn ); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CS60MetaConnectionProvider::Policy |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CMPMPolicyRequests* CS60MetaConnectionProvider::Policy() |
|
147 { |
|
148 return iPolicy; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CS60MetaConnectionProvider::RequestPermissionToSendStarted |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TBool CS60MetaConnectionProvider::RequestPermissionToSendStarted() |
|
156 { |
|
157 if ( !iDataClientStatusStarted ) |
|
158 { |
|
159 iDataClientStatusStarted = ETrue; |
|
160 return ETrue; |
|
161 } |
|
162 else |
|
163 { |
|
164 return EFalse; |
|
165 } |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CS60MetaConnectionProvider::RequestPermissionToSendStopped |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 TBool CS60MetaConnectionProvider::RequestPermissionToSendStopped() |
|
173 { |
|
174 if ( iDataClientStatusStarted ) |
|
175 { |
|
176 iDataClientStatusStarted = EFalse; |
|
177 return ETrue; |
|
178 } |
|
179 else |
|
180 { |
|
181 return EFalse; |
|
182 } |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CS60MetaConnectionProvider::PolicyPrefs |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TPolicyConnPref& CS60MetaConnectionProvider::PolicyPrefs() |
|
190 { |
|
191 return iPolicyPrefs; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CS60MetaConnectionProvider::SetPolicyPrefs |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CS60MetaConnectionProvider::SetPolicyPrefs( TPolicyConnPref& aPrefs ) |
|
199 { |
|
200 iPolicyPrefs = aPrefs; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CS60MetaConnectionProvider::SetSelectionPrefs |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CS60MetaConnectionProvider::SetSelectionPrefs( TSelectionPrefs& aPrefs ) |
|
208 { |
|
209 iOrigPrefs = aPrefs; |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CS60MetaConnectionProvider::SelectionPrefs |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 const TSelectionPrefs& CS60MetaConnectionProvider::SelectionPrefs() |
|
217 { |
|
218 return iOrigPrefs; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CS60MetaConnectionProvider::SetConnPrefList |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CS60MetaConnectionProvider::SetConnPrefList( const ESock::RConnPrefList &aConnPrefList ) |
|
226 { |
|
227 iConnPrefList = aConnPrefList; |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CS60MetaConnectionProvider::ConnPrefList |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 ESock::RConnPrefList CS60MetaConnectionProvider::ConnPrefList() const |
|
235 { |
|
236 return iConnPrefList; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CS60MetaConnectionProvider::SetSubSessionUniqueId |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CS60MetaConnectionProvider::SetSubSessionUniqueId( const TSubSessionUniqueId aSubSessionUniqueId) |
|
244 { |
|
245 iSubSessionUniqueId = aSubSessionUniqueId; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CS60MetaConnectionProvider::SubSessionUniqueId |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TSubSessionUniqueId CS60MetaConnectionProvider::SubSessionUniqueId() const |
|
253 { |
|
254 return iSubSessionUniqueId; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CS60MetaConnectionProvider::IsHandshakingNow |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 TBool CS60MetaConnectionProvider::IsHandshakingNow() const |
|
262 { |
|
263 return iIsHandshakingNow; |
|
264 } |
|
265 |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CS60MetaConnectionProvider::SetHandshakingFlag |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CS60MetaConnectionProvider::SetHandshakingFlag() |
|
272 { |
|
273 iIsHandshakingNow = ETrue; |
|
274 } |
|
275 |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CS60MetaConnectionProvider::ClearHandshakingFlag |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CS60MetaConnectionProvider::ClearHandshakingFlag() |
|
282 { |
|
283 iIsHandshakingNow = EFalse; |
|
284 } |
|
285 |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CS60MetaConnectionProvider::PolicyNotification |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void CS60MetaConnectionProvider::PolicyNotification( TMpmNotification& aNotification ) |
|
292 { |
|
293 switch ( aNotification.iMPMNotificationType ) |
|
294 { |
|
295 case EMPMPreferredIAPAvailable: |
|
296 { |
|
297 TMpmNotificationPrefIAPAvailable& notification = |
|
298 static_cast<TMpmNotificationPrefIAPAvailable&>( |
|
299 const_cast<TMpmNotification&>( aNotification ) ); |
|
300 |
|
301 //HandlePreferredIAPAvailable( const_cast<TMpmNotificationPrefIAPAvailable&>( notification ) ); |
|
302 |
|
303 // Check if the TPrefIAPNotifInfo contains new or old IAP. |
|
304 // |
|
305 if ( ServiceProvider() && |
|
306 ((RMetaServiceProviderInterface*)ServiceProvider())->ProviderInfo().APId() != notification.iNewIapId ) |
|
307 { |
|
308 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMPreferredIAPAvailable IAP %d",(TInt*)this,notification.iNewIapId); |
|
309 |
|
310 // Store PolicyNotification |
|
311 // This could happen if PolicyServer sends notification too early. |
|
312 // |
|
313 StorePolicyNotification( aNotification ); |
|
314 |
|
315 // Send preferred carrier message into meshmachine. |
|
316 // |
|
317 RNodeInterface ni; |
|
318 ni.OpenPostMessageClose( NodeId(), |
|
319 NodeId(), |
|
320 TCFS60MCPRMessage::TMPMPreferredCarrierAvailableMsg( (TAny*)¬ification ).CRef() ); |
|
321 } |
|
322 #ifdef _DEBUG |
|
323 else |
|
324 { |
|
325 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMPreferredIAPAvailable SAME IAP %d",(TInt*)this,notification.iNewIapId ); |
|
326 } |
|
327 #endif |
|
328 break; |
|
329 } |
|
330 case EMPMMobilityErrorNotification: |
|
331 { |
|
332 TMpmNotificationError& notification = |
|
333 static_cast<TMpmNotificationError&>( |
|
334 const_cast<TMpmNotification&>( aNotification ) ); |
|
335 |
|
336 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMMobilityErrorNotification %d",(TInt*)this,notification.iError); |
|
337 |
|
338 // Store PolicyNotification |
|
339 // This could happen if PolicyServer sends notification too early. |
|
340 // |
|
341 StorePolicyNotification( aNotification ); |
|
342 |
|
343 // Send error notification into meshmachine. |
|
344 // |
|
345 RNodeInterface ni; |
|
346 ni.OpenPostMessageClose( NodeId(), |
|
347 NodeId(), |
|
348 TCFS60MCPRMessage::TMPMErrorNotificationMsg( notification.iError ).CRef() ); |
|
349 break; |
|
350 } |
|
351 |
|
352 case EMPMClientErrorNotification: |
|
353 { |
|
354 TMpmNotificationError& notification = |
|
355 static_cast<TMpmNotificationError&>( |
|
356 const_cast<TMpmNotification&>( aNotification ) ); |
|
357 |
|
358 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMClientErrorNotification %d",(TInt*)this,notification.iError); |
|
359 |
|
360 PostToClients<TDefaultClientMatchPolicy>( TNodeCtxId( 0, Id() ), |
|
361 TCFDataClient::TStop( notification.iError ).CRef(), |
|
362 TClientType( TCFClientType::EData) ); |
|
363 break; |
|
364 } |
|
365 |
|
366 case EMPMStartIAPNotification: |
|
367 { |
|
368 TMpmNotificationStartIAP& notification = |
|
369 static_cast<TMpmNotificationStartIAP&>( |
|
370 const_cast<TMpmNotification&>( aNotification ) ); |
|
371 |
|
372 const TStartIAPNotifInfo& info = notification.iInfo; |
|
373 |
|
374 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMStartIAPNotification IAP %d",(TInt*)this,info.iIap); |
|
375 |
|
376 // Store PolicyNotification |
|
377 // This could happen if PolicyServer sends notification too early. |
|
378 // |
|
379 StorePolicyNotification( aNotification ); |
|
380 |
|
381 // The TMPMStartIAPNotificationMsg only has effect if there's an activity waiting for it. |
|
382 // |
|
383 RNodeInterface ni; |
|
384 ni.OpenPostMessageClose( NodeId(), |
|
385 NodeId(), |
|
386 TCFS60MCPRMessage::TMPMStartIAPNotificationMsg( info.iIap ).CRef() ); |
|
387 break; |
|
388 } |
|
389 case EMPMStopIAPNotification: |
|
390 { |
|
391 TMpmNotificationStopIAP& notification = |
|
392 static_cast<TMpmNotificationStopIAP&>( const_cast<TMpmNotification&>( aNotification ) ); |
|
393 |
|
394 // Allow TStop message only when ServiceProvider exists and the IAP matches or is unspecified. |
|
395 // |
|
396 if ( ServiceProvider() && |
|
397 (((RMetaServiceProviderInterface*)ServiceProvider())->ProviderInfo().APId() == notification.iInfo.iIap || |
|
398 notification.iInfo.iIap == 0 )) |
|
399 { |
|
400 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMStopIAPNotification IAP %d",(TInt*)this,notification.iInfo.iIap); |
|
401 |
|
402 //TODO migrate to use MCPR's TStop and vertical msg down. Not supported at the moment. |
|
403 /*PostToClients<TDefaultClientMatchPolicy>( TNodeCtxId( 0, Id() ), |
|
404 TCFServiceProvider::TStop( KErrCancel ).CRef(), |
|
405 TClientType( TCFClientType::EData) );*/ |
|
406 } |
|
407 #ifdef _DEBUG |
|
408 else |
|
409 { |
|
410 S60MCPRLOGSTRING2("S60MCPR<%x>::PolicyNotification() EMPMStopIAPNotification NO MATCH! IAP %d",(TInt*)this,notification.iInfo.iIap); |
|
411 } |
|
412 #endif |
|
413 break; |
|
414 } |
|
415 default: |
|
416 { |
|
417 #ifdef _DEBUG |
|
418 // In debug builds, panic |
|
419 _LIT( KPanicMsg, |
|
420 "S60MCPR::NotificationReceived: Invalid case" ); |
|
421 User::Panic( KPanicMsg, KErrNotSupported ); |
|
422 #endif |
|
423 break; |
|
424 } |
|
425 } |
|
426 } |
|
427 |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CS60MetaConnectionProvider::ReSendPolicyNotification |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CS60MetaConnectionProvider::ReSendPolicyNotification() |
|
434 { |
|
435 if ( iPendingNotification.Length() > 0 ) |
|
436 { |
|
437 // Typically deliver the notification and resubmit a request for new one. |
|
438 TUint8* msgBufferPtr = const_cast<TUint8*>( iPendingNotification.Ptr() ); |
|
439 TMpmNotification* notification = reinterpret_cast<TMpmNotification*>( msgBufferPtr ); |
|
440 |
|
441 S60MCPRLOGSTRING1("S60MCPR<%x>::ReSendPolicyNotification()",(TInt*)this); |
|
442 |
|
443 PolicyNotification( *const_cast<TMpmNotification*>( notification ) ); |
|
444 } |
|
445 } |
|
446 |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // CS60MetaConnectionProvider::ClearPolicyNotification |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 void CS60MetaConnectionProvider::ClearPolicyNotification() |
|
453 { |
|
454 iPendingNotification.Zero(); |
|
455 } |
|
456 |
|
457 |
|
458 // ----------------------------------------------------------------------------- |
|
459 // CS60MetaConnectionProvider::StorePolicyNotification |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 void CS60MetaConnectionProvider::StorePolicyNotification( TMpmNotification& aNotification ) |
|
463 { |
|
464 // Store PolicyNotification |
|
465 // This could happen if PolicyServer sends notification too early. |
|
466 // |
|
467 if ( iPendingNotification.Length() == 0 ) |
|
468 { |
|
469 ASSERT(Mem::Copy((TAny*)iPendingNotification.Ptr(), &aNotification, aNotification.Length())); |
|
470 iPendingNotification.SetLength( aNotification.Length() ); |
|
471 } |
|
472 #ifdef _DEBUG |
|
473 else |
|
474 { |
|
475 S60MCPRLOGSTRING2("S60MCPR<%x>::StorePolicyNotification() Notification already exists", |
|
476 (TInt*)this, reinterpret_cast<TMpmNotification*>( &iPendingNotification )->iMPMNotificationType); |
|
477 } |
|
478 #endif |
|
479 } |
|
480 |
|
481 // End of file |
|
482 |