|
1 /* |
|
2 * Copyright (c) 2005-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: Get events from Connection Monitor |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file mpmconnmonevents.cpp |
|
20 Get events from Connection Monitor. |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "mpmconnmonevents.h" |
|
25 #include "mpmconnmonreqs.h" |
|
26 #include "mpmserver.h" |
|
27 #include "mpmserversession.h" |
|
28 #include "mpmlogger.h" |
|
29 #include "mpmwlanavailability.h" |
|
30 |
|
31 // ============================= LOCAL FUNCTIONS =============================== |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMPMConnMonEvents::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMPMConnMonEvents* CMPMConnMonEvents::NewL( CMPMServer& aServer, |
|
40 CMPMServerSession& aSession ) |
|
41 { |
|
42 CMPMConnMonEvents* self = new ( ELeave ) CMPMConnMonEvents( aServer ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aSession ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMPMConnMonEvents::CMPMConnMonEvents |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMPMConnMonEvents::CMPMConnMonEvents( CMPMServer& aServer ) |
|
55 : iMyServer( aServer ), |
|
56 iDiscardAvailabilityNotification( EFalse ) |
|
57 { |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMPMConnMonEvents::~CMPMConnMonEvents |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CMPMConnMonEvents::~CMPMConnMonEvents() |
|
66 { |
|
67 iConnMon.CancelNotifications(); |
|
68 iConnMon.Close(); |
|
69 iReqPtrs.ResetAndDestroy(); |
|
70 iConnInfoArray.Close(); |
|
71 delete iWlanAvailability; |
|
72 iWlanAvailability = NULL; |
|
73 } |
|
74 |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CMPMConnMonEvents::ConstructL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CMPMConnMonEvents::ConstructL( CMPMServerSession& aSession ) |
|
81 { |
|
82 MPMLOGSTRING( "CMPMConnMonEvents::ConstructL" ) |
|
83 // Connect to Connection Monitor |
|
84 // |
|
85 TInt rv = iConnMon.ConnectL(); |
|
86 if ( rv != KErrNone ) |
|
87 { |
|
88 MPMLOGSTRING2( |
|
89 "CMPMConnMonEvents::ConstructL error connecting to ConnMon %d", |
|
90 rv ) |
|
91 User::Leave( rv ); |
|
92 } |
|
93 |
|
94 // Request for available IAPs |
|
95 // |
|
96 CMPMConnMonReqs* req = CMPMConnMonReqs::NewL( |
|
97 *const_cast<CMPMConnMonEvents*>( this ), |
|
98 iConnMon, |
|
99 aSession.ConnectionId(), aSession ); |
|
100 CleanupStack::PushL( req ); |
|
101 iReqPtrs.AppendL( req ); |
|
102 req->AvailableIapsSync(); |
|
103 |
|
104 UpdateIAPRefreshTime(); |
|
105 |
|
106 // Activate event notifications |
|
107 // |
|
108 iConnMon.NotifyEventL( *this ); |
|
109 CleanupStack::Pop( req ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMPMConnMonEvents::RemoveReqPtr |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMPMConnMonEvents::RemoveReqPtr( const CMPMConnMonReqs* aReq ) |
|
118 { |
|
119 TInt index( KErrNotFound ); |
|
120 |
|
121 index = iReqPtrs.Find( aReq ); |
|
122 if ( index != KErrNotFound ) |
|
123 { |
|
124 iReqPtrs.Remove( index ); |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CMPMConnMonEvents::AppendConnInfo |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CMPMConnMonEvents::AppendConnInfo( const TUint& aConnId ) |
|
134 { |
|
135 TInt index( KErrNotFound ); |
|
136 TConnInfo info; |
|
137 |
|
138 info.iConnId = aConnId; |
|
139 index = iConnInfoArray.Find( info ); |
|
140 |
|
141 if ( index == KErrNotFound ) |
|
142 { |
|
143 iConnInfoArray.Append( info ); |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CMPMConnMonEvents::RemoveConnInfo |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CMPMConnMonEvents::RemoveConnInfo( const TUint& aConnId ) |
|
153 { |
|
154 TInt index( KErrNotFound ); |
|
155 TConnInfo info; |
|
156 |
|
157 info.iConnId = aConnId; |
|
158 index = iConnInfoArray.Find( info ); |
|
159 |
|
160 if ( ( index != KErrNotFound ) && ( index < iConnInfoArray.Count() ) ) |
|
161 { |
|
162 iConnInfoArray.Remove( index ); |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CMPMConnMonEvents::SetConnInfo |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CMPMConnMonEvents::SetConnInfo( const TUint& aConnId, |
|
172 const TUint& aIapId, |
|
173 const TUint& aPresumedIapId, |
|
174 const TUint& aNetId, |
|
175 const TDesC& aAPN ) |
|
176 { |
|
177 TInt index( KErrNotFound ); |
|
178 TConnInfo info; |
|
179 |
|
180 info.iConnId = aConnId; |
|
181 index = iConnInfoArray.Find( info ); |
|
182 |
|
183 if ( ( index != KErrNotFound ) && ( index < iConnInfoArray.Count() ) ) |
|
184 { |
|
185 MPMLOGSTRING3( |
|
186 "CMPMConnMonEvents::SetConnInfo - aConnId = 0x%x, APN = %S", |
|
187 aConnId, &aAPN ) |
|
188 iConnInfoArray[index].iIapId = TUint32( aIapId ); |
|
189 iConnInfoArray[index].iNetId = TUint32( aNetId ); |
|
190 iConnInfoArray[index].iAPN.Copy( aAPN ); |
|
191 iConnInfoArray[index].iSSID.FillZ(); |
|
192 iConnInfoArray[index].iSSID.Zero(); |
|
193 iConnInfoArray[index].iPresumedIapId = TUint32( aPresumedIapId ); |
|
194 iConnInfoArray[index].iConnType = EConnectionGPRS; |
|
195 } |
|
196 else |
|
197 { |
|
198 MPMLOGSTRING2( |
|
199 "CMPMConnMonEvents::SetConnInfo - aConnId = 0x%x not found", |
|
200 aConnId ) |
|
201 } |
|
202 } |
|
203 |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CMPMConnMonEvents::SetConnInfo |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CMPMConnMonEvents::SetConnInfo( const TUint& aConnId, |
|
210 const TUint& aIapId, |
|
211 const TUint& aPresumedIapId, |
|
212 const TUint& aNetId, |
|
213 const TWlanSsid& aSSID ) |
|
214 { |
|
215 TInt index( KErrNotFound ); |
|
216 TConnInfo info; |
|
217 |
|
218 info.iConnId = aConnId; |
|
219 index = iConnInfoArray.Find( info ); |
|
220 |
|
221 if ( ( index != KErrNotFound ) && ( index < iConnInfoArray.Count() ) ) |
|
222 { |
|
223 MPMLOGSSID( |
|
224 "CMPMConnMonEvents::SetConnInfo - aConnId = 0x%x, SSID = %S", |
|
225 aConnId, &aSSID ) |
|
226 |
|
227 iConnInfoArray[index].iIapId = TUint32( aIapId ); |
|
228 iConnInfoArray[index].iNetId = TUint32( aNetId ); |
|
229 iConnInfoArray[index].iAPN.FillZ(); |
|
230 iConnInfoArray[index].iAPN.Zero(); |
|
231 iConnInfoArray[index].iSSID.Copy( aSSID ); |
|
232 iConnInfoArray[index].iPresumedIapId = TUint32( aPresumedIapId ); |
|
233 iConnInfoArray[index].iConnType = EConnectionWLAN; |
|
234 } |
|
235 else |
|
236 { |
|
237 MPMLOGSTRING2( |
|
238 "CMPMConnMonEvents::SetConnInfo - aConnId = 0x%x not found", |
|
239 aConnId ) |
|
240 } |
|
241 } |
|
242 |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CMPMConnMonEvents::SetConnInfoIapSsid |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CMPMConnMonEvents::SetConnInfoIapSsid( const TUint& aIapId, |
|
249 const TWlanSsid& aSSID ) |
|
250 { |
|
251 |
|
252 for ( TInt i( 0 ); ( i < iConnInfoArray.Count() ); i++ ) |
|
253 { |
|
254 if ( iConnInfoArray[i].iIapId == aIapId ) |
|
255 { |
|
256 iConnInfoArray[i].iSSID.Copy( aSSID ); |
|
257 } |
|
258 } |
|
259 } |
|
260 |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CMPMConnMonEvents::ResetConnInfo |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 void CMPMConnMonEvents::ResetConnInfo( const TUint& aConnId ) |
|
267 { |
|
268 TInt index( KErrNotFound ); |
|
269 TConnInfo info; |
|
270 |
|
271 info.iConnId = aConnId; |
|
272 index = iConnInfoArray.Find( info ); |
|
273 |
|
274 if ( ( index != KErrNotFound ) && ( index < iConnInfoArray.Count() ) ) |
|
275 { |
|
276 MPMLOGSTRING2( |
|
277 "CMPMConnMonEvents::ResetConnInfo - aConnId = 0x%x reset", |
|
278 aConnId ) |
|
279 iConnInfoArray[index].iIapId = 0; |
|
280 iConnInfoArray[index].iNetId = 0; |
|
281 iConnInfoArray[index].iPresumedIapId = 0; |
|
282 iConnInfoArray[index].iAPN.FillZ(); |
|
283 iConnInfoArray[index].iAPN.Zero(); |
|
284 iConnInfoArray[index].iSSID.FillZ(); |
|
285 iConnInfoArray[index].iSSID.Zero(); |
|
286 iConnInfoArray[index].iConnType = EConnectionGeneric; |
|
287 } |
|
288 else |
|
289 { |
|
290 MPMLOGSTRING2( |
|
291 "CMPMConnMonEvents::ResetConnInfo - aConnId = 0x%x not found", |
|
292 aConnId ) |
|
293 } |
|
294 } |
|
295 |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CMPMConnMonEvents::ResetIapConnInfo |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 void CMPMConnMonEvents::ResetIapConnInfo( const TUint32 aIapId ) |
|
302 { |
|
303 |
|
304 // Reset all connections using aIapId |
|
305 // |
|
306 for ( TInt index( 0 ); ( index < iConnInfoArray.Count() ); index++ ) |
|
307 { |
|
308 if ( iConnInfoArray[index].iIapId == aIapId ) |
|
309 { |
|
310 MPMLOGSTRING2( |
|
311 "CMPMConnMonEvents::ResetIapConnInfo - ConnId = 0x%x reset", |
|
312 iConnInfoArray[index].iConnId ) |
|
313 iConnInfoArray[index].iIapId = 0; |
|
314 iConnInfoArray[index].iNetId = 0; |
|
315 iConnInfoArray[index].iPresumedIapId = 0; |
|
316 iConnInfoArray[index].iAPN.FillZ(); |
|
317 iConnInfoArray[index].iAPN.Zero(); |
|
318 iConnInfoArray[index].iSSID.FillZ(); |
|
319 iConnInfoArray[index].iSSID.Zero(); |
|
320 iConnInfoArray[index].iConnType = EConnectionGeneric; |
|
321 } |
|
322 } |
|
323 } |
|
324 |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CMPMConnMonEvents::GetAvailableIAPs |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 const TConnMonIapInfo& CMPMConnMonEvents::GetAvailableIAPs() |
|
331 { |
|
332 return iAvailableIAPs; |
|
333 } |
|
334 |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CMPMConnMonEvents::SetAvailableIAPs |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CMPMConnMonEvents::SetAvailableIAPs( |
|
341 const TConnMonIapInfo& aAvailableIAPs ) |
|
342 { |
|
343 iAvailableIAPs = aAvailableIAPs; |
|
344 |
|
345 UpdateIAPRefreshTime(); |
|
346 |
|
347 MPMLOGSTRING2( "CMPMConnMonEvents::SetAvailableIAPs - IAPs count: %d", |
|
348 iAvailableIAPs.Count() ) |
|
349 |
|
350 #ifdef _DEBUG |
|
351 for ( TUint i = 0; i < iAvailableIAPs.Count(); i++ ) |
|
352 { |
|
353 MPMLOGSTRING2( "CMPMConnMonEvents::SetAvailableIAPs - IAP: %d", |
|
354 iAvailableIAPs.iIap[i].iIapId) |
|
355 } |
|
356 #endif // _DEBUG |
|
357 } |
|
358 |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CMPMConnMonEvents::FindAPN |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CMPMConnMonEvents::FindAPN( const TDesC& aDes, |
|
365 TUint32& aIapId, |
|
366 TUint32& aNetId ) |
|
367 { |
|
368 TBool apnFound( EFalse ); |
|
369 |
|
370 for ( TInt i( 0 ); ( (i < iConnInfoArray.Count()) && !apnFound ); i++ ) |
|
371 { |
|
372 if ( ( aDes.Compare( iConnInfoArray[i].iAPN ) == KErrNone ) && |
|
373 ( iConnInfoArray[i].iConnType == EConnectionGPRS ) ) |
|
374 { |
|
375 aIapId = iConnInfoArray[i].iIapId; |
|
376 aNetId = iConnInfoArray[i].iNetId; |
|
377 MPMLOGSTRING2( "CMPMConnMonEvents::FindAPN found Iap Id: %i", |
|
378 aIapId) |
|
379 MPMLOGSTRING2( "CMPMConnMonEvents::FindAPN found Net Id: %i", |
|
380 aNetId) |
|
381 apnFound = ETrue; |
|
382 } |
|
383 } |
|
384 } |
|
385 |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // CMPMConnMonEvents::FindSSID |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CMPMConnMonEvents::FindSSID( const TWlanSsid& aSSID, |
|
392 TUint32& aIapId, |
|
393 TUint32& aNetId ) |
|
394 { |
|
395 TBool ssidFound( EFalse ); |
|
396 |
|
397 for ( TInt i( 0 ); ( (i < iConnInfoArray.Count()) && !ssidFound ); i++ ) |
|
398 { |
|
399 if ( ( aSSID.Compare( iConnInfoArray[i].iSSID ) == KErrNone ) && |
|
400 ( iConnInfoArray[i].iConnType == EConnectionWLAN ) ) |
|
401 { |
|
402 aIapId = iConnInfoArray[i].iIapId; |
|
403 aNetId = iConnInfoArray[i].iNetId; |
|
404 MPMLOGSTRING2( "CMPMConnMonEvents::FindSSID found Iap Id: %i", |
|
405 aIapId) |
|
406 MPMLOGSTRING2( "CMPMConnMonEvents::FindSSID found Net Id: %i", |
|
407 aNetId) |
|
408 ssidFound = ETrue; |
|
409 } |
|
410 } |
|
411 } |
|
412 |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CMPMConnMonEvents::ActiveWlanConnection |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 TBool CMPMConnMonEvents::ActiveWlanConnection( TWlanSsid& aSSID, |
|
419 TUint32& aIapId ) |
|
420 { |
|
421 TWlanSsid emptySSID; |
|
422 TBool activeWlanFound( EFalse ); |
|
423 |
|
424 emptySSID.FillZ(); |
|
425 emptySSID.Zero(); |
|
426 |
|
427 for ( TInt i( 0 ); ( (i < iConnInfoArray.Count()) && !activeWlanFound ); |
|
428 i++ ) |
|
429 { |
|
430 if ( emptySSID.Compare( iConnInfoArray[i].iSSID ) != KErrNone ) |
|
431 { |
|
432 // Cross check that a started connection with the wlan IAP |
|
433 // is found from ActiveBMConnections |
|
434 // |
|
435 TUint32 connIap = iMyServer.GetBMIap( iConnInfoArray[i].iConnId ); |
|
436 TConnectionState connState; |
|
437 iMyServer.GetConnectionState( iConnInfoArray[i].iConnId, connState ); |
|
438 if( connIap == iConnInfoArray[i].iIapId && |
|
439 connState == EStarted ) |
|
440 { |
|
441 aSSID.Copy( iConnInfoArray[i].iSSID ); |
|
442 aIapId = iConnInfoArray[i].iIapId; |
|
443 activeWlanFound = ETrue; |
|
444 |
|
445 MPMLOGSSID( "CMPMConnMonEvents::ActiveWlanConnection found\ |
|
446 ConnId = 0x%x, SSID = %S", iConnInfoArray[i].iConnId, &aSSID ) |
|
447 |
|
448 MPMLOGSTRING2( |
|
449 "CMPMConnMonEvents::ActiveWlanConnection found Iap Id: %i", |
|
450 iConnInfoArray[i].iIapId ) |
|
451 } |
|
452 else |
|
453 { |
|
454 MPMLOGSSID( "CMPMConnMonEvents::ActiveWlanConnection found\ |
|
455 but connection not in started state ConnId = 0x%x, SSID = %S", |
|
456 iConnInfoArray[i].iConnId, &aSSID ) |
|
457 } |
|
458 } |
|
459 } |
|
460 return activeWlanFound; |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CMPMConnMonEvents::IapAvailabilityChange |
|
465 // ----------------------------------------------------------------------------- |
|
466 // |
|
467 void CMPMConnMonEvents::IapAvailabilityChange() |
|
468 { |
|
469 if ( ( iAvailableIAPs.Count() > 0 ) && |
|
470 !DiscardAvailabilityNotification() ) |
|
471 { |
|
472 // Remove temporary blacklistings as fresh availability |
|
473 // info is available. |
|
474 // |
|
475 iMyServer.HandleServerUnblackListIap( ETemporary ); |
|
476 |
|
477 // Send preferred IAP notifications, but DO NOT LEAVE |
|
478 // or Connection Monitor CConnMonEventHandler::RunL() |
|
479 // will also leave, which will make mpmserver.exe CRASH. |
|
480 // |
|
481 TRAP_IGNORE( iMyServer.NotifyBMPrefIapL( iAvailableIAPs ) ) |
|
482 } |
|
483 else |
|
484 { |
|
485 MPMLOGSTRING2( "CMPMConnMonEvents::EventL - IAPs count: %d", |
|
486 iAvailableIAPs.Count() ) |
|
487 MPMLOGSTRING2( |
|
488 "CMPMConnMonEvents::EventL - DiscardAvailabilityNotification = %d", |
|
489 DiscardAvailabilityNotification() ) |
|
490 } |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CMPMConnMonEvents::EventL |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 void CMPMConnMonEvents::EventL( const CConnMonEventBase& aConnMonEvent ) |
|
498 { |
|
499 MPMLOGSTRING2( "CMPMConnMonEvents::EventL %d", aConnMonEvent.EventType()) |
|
500 |
|
501 switch ( aConnMonEvent.EventType() ) |
|
502 { |
|
503 case EConnMonCreateConnection: |
|
504 { |
|
505 MPMLOGSTRING( " EConnMonCreateConnection" ) |
|
506 iMyServer.IncrementConnections(); |
|
507 break; |
|
508 } |
|
509 case EConnMonDeleteConnection: |
|
510 { |
|
511 MPMLOGSTRING( " EConnMonDeleteConnection" ) |
|
512 iMyServer.DecrementConnections(); |
|
513 break; |
|
514 } |
|
515 case EConnMonIapAvailabilityChange: |
|
516 { |
|
517 #ifdef __DEBUG |
|
518 if ( iFilterEvents == ETrue ) |
|
519 { |
|
520 MPMLOGSTRING( " EConnMonIapAvailabilityChange FILTERED OUT" ) |
|
521 return; |
|
522 } |
|
523 #endif //__DEBUG |
|
524 // IAP Availability has changed |
|
525 // |
|
526 MPMLOGSTRING( " EConnMonIapAvailabilityChange" ) |
|
527 |
|
528 const CConnMonIapAvailabilityChange* eventIap; |
|
529 |
|
530 // Following line is correct, even though |
|
531 // PC-Lint claims that here is a problem: |
|
532 // |
|
533 // Suspicious pointer-to-pointer conversion (area too small) |
|
534 // |
|
535 eventIap = static_cast<const CConnMonIapAvailabilityChange*>( |
|
536 &aConnMonEvent ); |
|
537 |
|
538 iAvailableIAPs = eventIap->IapAvailability(); |
|
539 UpdateIAPRefreshTime(); |
|
540 IapAvailabilityChange(); |
|
541 |
|
542 TRAPD( err, iMyServer.UpdateSessionConnectionDlgL() ) |
|
543 if( err != KErrNone ) |
|
544 { |
|
545 MPMLOGSTRING2( "CMPMConnMonEvents::EventL UpdateSessionConnectionDlgL \ |
|
546 error code %d", err ) |
|
547 } |
|
548 break; |
|
549 } |
|
550 default: |
|
551 { |
|
552 MPMLOGSTRING( "CMPMConnMonEvents::RunL: default" ) |
|
553 break; |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CMPMConnMonEvents::ScanWLANNetworksL |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 void CMPMConnMonEvents::ScanWLANNetworksL( CMPMServerSession* aSession, |
|
564 const TConnectionId& aId, |
|
565 TWlanScanCallback aCallback, |
|
566 TInt aForceRefreshIntervalSeconds ) |
|
567 { |
|
568 MPMLOGSTRING( "CMPMConnMonEvents::ScanWLANNetworksL" ) |
|
569 // Sanity check null pointer |
|
570 ASSERT( aSession != NULL |
|
571 || aCallback == EWlanScanCallbackNone |
|
572 || aCallback == EWlanScanCallbackGenerateEvent ); |
|
573 // Request for available WLAN Networks |
|
574 // |
|
575 CMPMConnMonReqs* req = CMPMConnMonReqs::NewL( |
|
576 *const_cast<CMPMConnMonEvents*>( this ), |
|
577 iConnMon, |
|
578 aId, |
|
579 *aSession ); |
|
580 CleanupStack::PushL( req ); |
|
581 iReqPtrs.AppendL( req ); |
|
582 req->RefreshAvailableIAPs( aCallback, aForceRefreshIntervalSeconds ); |
|
583 CleanupStack::Pop( req ); |
|
584 } |
|
585 |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CMPMConnMonEvents::CancelScanL |
|
589 // ----------------------------------------------------------------------------- |
|
590 // |
|
591 void CMPMConnMonEvents::CancelScanL( CMPMServerSession& aSession ) |
|
592 { |
|
593 MPMLOGSTRING( "CMPMConnMonEvents::CancelScanL" ) |
|
594 |
|
595 // Disable discarding availability notifications from Connection Monitor. |
|
596 // |
|
597 DisableDiscarding(); |
|
598 |
|
599 CMPMConnMonReqs* req = CMPMConnMonReqs::NewL( |
|
600 *const_cast<CMPMConnMonEvents*>( this ), |
|
601 iConnMon, |
|
602 aSession.ConnectionId(), |
|
603 aSession ); |
|
604 // Delete ongoing req, if found |
|
605 TInt index = iReqPtrs.Find(req, CMPMConnMonReqs::CompareConnIds); |
|
606 if (index != KErrNotFound) |
|
607 { |
|
608 // Instead of delete iReqPtrs[index] |
|
609 // We just mark it as obsolete. |
|
610 iReqPtrs[index]->MyCancel(); |
|
611 // And we can remove the index as the request will handle the deletion. |
|
612 iReqPtrs.Remove(index); |
|
613 } |
|
614 // Finally delete the temporary object. |
|
615 delete req; |
|
616 } |
|
617 |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CMPMConnMonEvents::PresumedIapId |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 TUint32 CMPMConnMonEvents::PresumedIapId( const TUint& aConnId, |
|
624 const TUint& aIapId ) |
|
625 { |
|
626 |
|
627 for ( TInt i( 0 ); ( i < iConnInfoArray.Count() ); i++ ) |
|
628 { |
|
629 if ( iConnInfoArray[i].iConnId == aConnId && |
|
630 iConnInfoArray[i].iIapId == aIapId ) |
|
631 { |
|
632 if ( iConnInfoArray[i].iPresumedIapId == 0 ) |
|
633 { |
|
634 // Iap Id zero is not a valid Iap Id |
|
635 // |
|
636 return aIapId; |
|
637 } |
|
638 else |
|
639 { |
|
640 MPMLOGSTRING2( |
|
641 "CMPMConnMonEvents::PresumedIapId found Iap: %i", |
|
642 iConnInfoArray[i].iPresumedIapId ) |
|
643 |
|
644 return iConnInfoArray[i].iPresumedIapId; |
|
645 } |
|
646 } |
|
647 } |
|
648 |
|
649 // PresumedIapId returns aIapId in case no presumed IAP info is found. |
|
650 // |
|
651 return aIapId; |
|
652 } |
|
653 |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // CMPMConnMonEvents::UpdateIAPRefreshTime |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 void CMPMConnMonEvents::UpdateIAPRefreshTime() |
|
660 { |
|
661 iLastIAPRefreshTime.UniversalTime(); |
|
662 } |
|
663 |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CMPMConnMonEvents::GetIAPRefreshTime |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 TTime& CMPMConnMonEvents::GetIAPRefreshTime() |
|
670 { |
|
671 return iLastIAPRefreshTime; |
|
672 } |
|
673 |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CMPMConnMonEvents::SetConnectionCounter |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 void CMPMConnMonEvents::SetConnectionCounter( const TUint aValue ) |
|
680 { |
|
681 iMyServer.SetConnectionCounter( aValue ); |
|
682 } |
|
683 |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // TConnInfo::TConnInfo |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 TConnInfo::TConnInfo() |
|
690 : iConnId( 0 ), |
|
691 iIapId( 0 ), |
|
692 iPresumedIapId( 0 ), |
|
693 iNetId( 0 ), |
|
694 iAPN(), |
|
695 iSSID(), |
|
696 iConnType( EConnectionGeneric ) |
|
697 { |
|
698 } |
|
699 |
|
700 // ----------------------------------------------------------------------------- |
|
701 // CMPMConnMonEvents::CheckWlanAvailabilityL |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 void CMPMConnMonEvents::CheckWlanAvailabilityL( MWlanAvailability* aObserver ) |
|
705 { |
|
706 MPMLOGSTRING( "CMPMConnMonEvents::CheckWlanAvailabilityL" ) |
|
707 // Sanity check null pointer |
|
708 ASSERT( aObserver != NULL ); |
|
709 |
|
710 // Request for WLAN bearer availability info |
|
711 // |
|
712 if ( !iWlanAvailability ) |
|
713 { |
|
714 iWlanAvailability = CWlanAvailability::NewL( this, iConnMon ); |
|
715 } |
|
716 |
|
717 iWlanAvailability->Start( aObserver ); |
|
718 } |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CMPMConnMonEvents::CancelCheckWlanWlanAvailability |
|
722 // ----------------------------------------------------------------------------- |
|
723 // |
|
724 void CMPMConnMonEvents::CancelCheckWlanWlanAvailability( MWlanAvailability* aObserver ) |
|
725 { |
|
726 MPMLOGSTRING( "CMPMConnMonEvents::CancelCheckWlanWlanAvailability" ) |
|
727 // Sanity check null pointer |
|
728 ASSERT( aObserver != NULL ); |
|
729 |
|
730 // Cancel WLAN bearer availability check for this observer |
|
731 // |
|
732 if ( iWlanAvailability ) |
|
733 { |
|
734 iWlanAvailability->CancelObserver( aObserver ); |
|
735 } |
|
736 } |
|
737 |
|
738 // ----------------------------------------------------------------------------- |
|
739 // CMPMConnMonEvents::SetWlanAvailabilityPtrNull |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 void CMPMConnMonEvents::SetWlanAvailabilityPtrNull() |
|
743 { |
|
744 iWlanAvailability = NULL; |
|
745 } |
|
746 |
|
747 // End of File |
|
748 |