26 // ----------------------------------------------------------------------------- |
26 // ----------------------------------------------------------------------------- |
27 // CSipAlrSnapMonitor::NewLC |
27 // CSipAlrSnapMonitor::NewLC |
28 // ----------------------------------------------------------------------------- |
28 // ----------------------------------------------------------------------------- |
29 // |
29 // |
30 CSipAlrSnapMonitor* CSipAlrSnapMonitor::NewLC( |
30 CSipAlrSnapMonitor* CSipAlrSnapMonitor::NewLC( |
31 TSipSNAPConfigurationData aSnapData, |
31 TUint32 aSnapId, |
32 MSipAlrObserver& aObserver, |
32 MSipAlrObserver& aObserver, |
33 RSocketServ& aSocketServer, |
33 RSocketServ& aSocketServer, |
34 CSipSystemStateMonitor& aSystemStateMonitor) |
34 CSipSystemStateMonitor& aSystemStateMonitor ) |
35 { |
35 { |
36 CSipAlrSnapMonitor* self = |
36 CSipAlrSnapMonitor* self = |
37 new ( ELeave ) CSipAlrSnapMonitor( |
37 new ( ELeave ) CSipAlrSnapMonitor( |
38 aSnapData, aSocketServer, aSystemStateMonitor); |
38 aSnapId, aSocketServer, aSystemStateMonitor ); |
39 CleanupStack::PushL( self ); |
39 CleanupStack::PushL( self ); |
40 self->ConstructL( aObserver ); |
40 self->ConstructL( aObserver ); |
41 return self; |
41 return self; |
42 } |
42 } |
43 |
43 |
44 // ----------------------------------------------------------------------------- |
44 // ----------------------------------------------------------------------------- |
45 // CSipAlrSnapMonitor::CSipAlrSnapMonitor |
45 // CSipAlrSnapMonitor::CSipAlrSnapMonitor |
46 // ----------------------------------------------------------------------------- |
46 // ----------------------------------------------------------------------------- |
47 // |
47 // |
48 CSipAlrSnapMonitor::CSipAlrSnapMonitor( |
48 CSipAlrSnapMonitor::CSipAlrSnapMonitor( |
49 TSipSNAPConfigurationData aSnapData, |
49 TUint32 aSnapId, |
50 RSocketServ& aSocketServer, |
50 RSocketServ& aSocketServer, |
51 CSipSystemStateMonitor& aSystemStateMonitor) : |
51 CSipSystemStateMonitor& aSystemStateMonitor ) : |
52 CActive ( CActive::EPriorityStandard ), |
52 CActive ( CActive::EPriorityStandard ), |
53 iSnapData( aSnapData ), |
53 iSnapId( aSnapId ), |
54 iSocketServer( aSocketServer ), |
54 iSocketServer( aSocketServer ), |
55 iSystemStateMonitor( aSystemStateMonitor ) |
55 iSystemStateMonitor( aSystemStateMonitor ) |
56 { |
56 { |
57 iPrefs.SetSnap( aSnapData.iSnapId ); |
57 iPrefs.SetSnap( iSnapId ); |
58 CActiveScheduler::Add( this ); |
58 CActiveScheduler::Add( this ); |
59 } |
59 } |
60 |
60 |
61 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
62 // CSipAlrSnapMonitor::ConstructL |
62 // CSipAlrSnapMonitor::ConstructL |
65 void CSipAlrSnapMonitor::ConstructL( MSipAlrObserver& aObserver ) |
65 void CSipAlrSnapMonitor::ConstructL( MSipAlrObserver& aObserver ) |
66 { |
66 { |
67 PROFILE_DEBUG1( "CSipAlrSnapMonitor::ConstructL entered" ) |
67 PROFILE_DEBUG1( "CSipAlrSnapMonitor::ConstructL entered" ) |
68 |
68 |
69 iSystemStateMonitor.StartMonitoringL( |
69 iSystemStateMonitor.StartMonitoringL( |
70 CSipSystemStateMonitor::ESnapAvailability, SnapId(), *this ); |
70 CSipSystemStateMonitor::ESnapAvailability, iSnapId, *this ); |
71 |
71 |
72 AddObserverL( aObserver ); |
72 AddObserverL( aObserver ); |
73 |
|
74 if(IsSnapAvailable()) |
|
75 { |
|
76 // SNAP is already Available to be started. |
|
77 // No Need to wait for Notification from System State Monitor. |
|
78 StartSnap(); |
|
79 } |
|
80 |
73 |
81 PROFILE_DEBUG1( "CSipAlrSnapMonitor::ConstructL returns" ) |
74 PROFILE_DEBUG1( "CSipAlrSnapMonitor::ConstructL returns" ) |
82 } |
75 } |
83 |
76 |
84 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
193 // |
186 // |
194 void CSipAlrSnapMonitor::NewCarrierActive( |
187 void CSipAlrSnapMonitor::NewCarrierActive( |
195 TAccessPointInfo aNewAP, |
188 TAccessPointInfo aNewAP, |
196 TBool /*aIsSeamless*/ ) |
189 TBool /*aIsSeamless*/ ) |
197 { |
190 { |
198 PROFILE_DEBUG3( "CSipSnapAlrMonitor::NewCarrierActive", SnapId() ) |
191 PROFILE_DEBUG3( "CSipSnapAlrMonitor::NewCarrierActive", iSnapId ) |
199 |
192 |
200 NotifyInitializedObservers( aNewAP.AccessPoint(), |
193 NotifyInitializedObservers( aNewAP.AccessPoint(), |
201 MSipAlrObserver::EIapActive ); |
194 MSipAlrObserver::EIapActive ); |
202 } |
195 } |
203 |
196 |
211 if ( !iCommsMobilityAO ) |
204 if ( !iCommsMobilityAO ) |
212 { |
205 { |
213 PROFILE_DEBUG1( "CSipSnapAlrMonitor::Error iCommsMobilityAO==NULL") |
206 PROFILE_DEBUG1( "CSipSnapAlrMonitor::Error iCommsMobilityAO==NULL") |
214 return; |
207 return; |
215 } |
208 } |
216 if ( aError == KErrNotFound && !BearerId()) |
209 if ( aError == KErrNotFound) |
217 { |
210 { |
218 NotifyInitializedObservers( KNoIap, |
211 NotifyInitializedObservers( KNoIap, |
219 MSipAlrObserver::ENoNewIapAvailable ); |
212 MSipAlrObserver::ENoNewIapAvailable ); |
220 } |
213 } |
221 |
214 |
222 // MMobilityProtocolResp::Error is called from ~CActiveCommsMobilityApiExt. |
215 // MMobilityProtocolResp::Error is called from ~CActiveCommsMobilityApiExt. |
223 // Flag iDying prevents starting the RConnection if not needed. |
216 // Flag iDying prevents starting the RConnection if not needed. |
224 if ( !iDying ) |
217 if ( !iDying ) |
225 { |
218 { |
226 ResetState(); |
219 ResetState(); |
227 if(!BearerId()) |
|
228 { |
|
229 PROFILE_DEBUG3( "CSipSnapAlrMonitor::Error, Start Snap as Bearer Id is ", BearerId() ) |
|
230 StartSnap(); |
220 StartSnap(); |
231 } |
|
232 } |
221 } |
233 } |
222 } |
234 |
223 |
235 // ----------------------------------------------------------------------------- |
224 // ----------------------------------------------------------------------------- |
236 // CSipAlrSnapMonitor::SystemVariableUpdated |
225 // CSipAlrSnapMonitor::SystemVariableUpdated |
244 PROFILE_DEBUG4( "CSipAlrSnapMonitor::SystemVariableUpdated, snap, value", |
233 PROFILE_DEBUG4( "CSipAlrSnapMonitor::SystemVariableUpdated, snap, value", |
245 aObjectId, aValue ) |
234 aObjectId, aValue ) |
246 |
235 |
247 if ( !IsActive() && |
236 if ( !IsActive() && |
248 aVariable == CSipSystemStateMonitor::ESnapAvailability && |
237 aVariable == CSipSystemStateMonitor::ESnapAvailability && |
249 aObjectId == SnapId() ) |
238 aObjectId == iSnapId ) |
250 { |
239 { |
251 if ( aValue == CSipSystemStateMonitor::ESnapAvailable ) |
240 if ( aValue == CSipSystemStateMonitor::ESnapAvailable ) |
252 { |
241 { |
253 if ( StartSnap() != KErrNone ) |
242 if ( StartSnap() != KErrNone ) |
254 { |
243 { |
266 // CSipAlrSnapMonitor::SnapId |
255 // CSipAlrSnapMonitor::SnapId |
267 // ----------------------------------------------------------------------------- |
256 // ----------------------------------------------------------------------------- |
268 // |
257 // |
269 TUint32 CSipAlrSnapMonitor::SnapId() const |
258 TUint32 CSipAlrSnapMonitor::SnapId() const |
270 { |
259 { |
271 return iSnapData.iSnapId; |
260 return iSnapId; |
272 } |
261 } |
273 |
262 |
274 // ----------------------------------------------------------------------------- |
263 // ----------------------------------------------------------------------------- |
275 // CSipAlrSnapMonitor::AddObserverL |
264 // CSipAlrSnapMonitor::AddObserverL |
276 // ----------------------------------------------------------------------------- |
265 // ----------------------------------------------------------------------------- |
334 // So after last AlrEvent(), don't access this object's data. |
322 // So after last AlrEvent(), don't access this object's data. |
335 PROFILE_DEBUG3( "CSipAlrSnapMonitor::RefreshL error", err ) |
323 PROFILE_DEBUG3( "CSipAlrSnapMonitor::RefreshL error", err ) |
336 for ( TInt i = iObservers.Count() - 1; i >= 0; --i ) |
324 for ( TInt i = iObservers.Count() - 1; i >= 0; --i ) |
337 { |
325 { |
338 iObservers[i].iObserver->AlrEvent( |
326 iObservers[i].iObserver->AlrEvent( |
339 MSipAlrObserver::ERefreshError, SnapId(), KNoIap ); |
327 MSipAlrObserver::ERefreshError, iSnapId, KNoIap ); |
340 } |
328 } |
341 } |
329 } |
342 } |
330 } |
343 |
331 |
344 PROFILE_DEBUG1( "CSipAlrSnapMonitor::Refresh returns" ) |
332 PROFILE_DEBUG1( "CSipAlrSnapMonitor::Refresh returns" ) |
412 // ----------------------------------------------------------------------------- |
400 // ----------------------------------------------------------------------------- |
413 // |
401 // |
414 TInt CSipAlrSnapMonitor::StartSnap() |
402 TInt CSipAlrSnapMonitor::StartSnap() |
415 { |
403 { |
416 PROFILE_DEBUG1( "CSipAlrSnapMonitor::StartSnap entered" ) |
404 PROFILE_DEBUG1( "CSipAlrSnapMonitor::StartSnap entered" ) |
|
405 |
417 TInt err = KErrNone; |
406 TInt err = KErrNone; |
418 if ( !IsActive() && IsSnapAvailable() ) |
407 if ( !IsActive() && IsSnapAvailable() ) |
419 { |
408 { |
420 PROFILE_DEBUG1( "CSipAlrSnapMonitor::StartSnap SNAP is available" ) |
409 PROFILE_DEBUG1( "CSipAlrSnapMonitor::StartSnap SNAP is available" ) |
421 |
410 |
422 err = iConnection.Open( iSocketServer ); |
411 err = iConnection.Open( iSocketServer ); |
423 PROFILE_DEBUG3( "CSipAlrSnapMonitor::StartSnap Open done, err=", err ) |
412 PROFILE_DEBUG3( "CSipAlrSnapMonitor::StartSnap Open done, err=", err ) |
424 |
413 |
425 if ( err == KErrNone ) |
414 if ( err == KErrNone ) |
426 { |
415 { |
427 if(BearerId()) |
416 iConnection.Start( iPrefs, iStatus ); |
428 { |
417 SetActive(); |
429 if(BearerId()== 1) |
|
430 { |
|
431 iExtPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN); |
|
432 } |
|
433 else if(BearerId() == 2) |
|
434 { |
|
435 iExtPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular); |
|
436 } |
|
437 PROFILE_DEBUG1( "CSipAlrSnapMonitor::Starting Bearer Filtered connection" ) |
|
438 iExtPrefs.SetSnapId( SnapId()); |
|
439 |
|
440 TRAPD(error, iPrefList.AppendL(&iExtPrefs)); |
|
441 if(error) |
|
442 { |
|
443 return error; |
|
444 } |
|
445 // Start connecting |
|
446 iConnection.Start( iPrefList, iStatus ); |
|
447 SetActive(); |
|
448 } |
|
449 else |
|
450 { |
|
451 PROFILE_DEBUG1( "CSipAlrSnapMonitor::Starting Normal Connection" ) |
|
452 iConnection.Start( iPrefs, iStatus ); |
|
453 SetActive(); |
|
454 } |
|
455 } |
418 } |
456 } |
419 } |
457 |
420 |
458 PROFILE_DEBUG3( "CSipAlrSnapMonitor::StartSnap returns", err ) |
421 PROFILE_DEBUG3( "CSipAlrSnapMonitor::StartSnap returns", err ) |
459 return err; |
422 return err; |
460 } |
423 } |
461 |
424 |
462 // ----------------------------------------------------------------------------- |
425 // ----------------------------------------------------------------------------- |
463 // CSipAlrSnapMonitor::CreateMobilityAoL |
426 // CSipAlrSnapMonitor::CreateMobilityAoL |
464 // ----------------------------------------------------------------------------- |
427 // ----------------------------------------------------------------------------- |
465 // |
428 // |
511 // ----------------------------------------------------------------------------- |
474 // ----------------------------------------------------------------------------- |
512 // |
475 // |
513 void CSipAlrSnapMonitor::NotifyObservers( TUint aIapId ) |
476 void CSipAlrSnapMonitor::NotifyObservers( TUint aIapId ) |
514 { |
477 { |
515 PROFILE_DEBUG4( "CSipSnapAlrMonitor::NotifyObservers SNAP, IAP", |
478 PROFILE_DEBUG4( "CSipSnapAlrMonitor::NotifyObservers SNAP, IAP", |
516 SnapId(), aIapId ) |
479 iSnapId, aIapId ) |
517 |
480 |
518 NotifyInitializedObservers( aIapId, MSipAlrObserver::EIapAvailable ); |
481 NotifyInitializedObservers( aIapId, MSipAlrObserver::EIapAvailable ); |
519 NotifyNewObservers( aIapId ); |
482 NotifyNewObservers( aIapId ); |
520 } |
483 } |
521 |
484 |
530 for (TInt i = iObservers.Count() - 1; i >= 0; --i) |
493 for (TInt i = iObservers.Count() - 1; i >= 0; --i) |
531 { |
494 { |
532 if ( iObservers[i].iInitialEventDone ) |
495 if ( iObservers[i].iInitialEventDone ) |
533 { |
496 { |
534 PROFILE_DEBUG3( "CSipAlrSnapMonitor::NotifyIntitializedObservers", |
497 PROFILE_DEBUG3( "CSipAlrSnapMonitor::NotifyIntitializedObservers", |
535 SnapId() ) |
498 iSnapId ) |
536 |
499 |
537 iObservers[i].iObserver->AlrEvent( aEvent, SnapId(), aIapId ); |
500 iObservers[i].iObserver->AlrEvent( aEvent, iSnapId, aIapId ); |
538 } |
501 } |
539 } |
502 } |
540 } |
503 } |
541 |
504 |
542 // ----------------------------------------------------------------------------- |
505 // ----------------------------------------------------------------------------- |
547 { |
510 { |
548 for ( TInt i = iObservers.Count() - 1; i >= 0; --i ) |
511 for ( TInt i = iObservers.Count() - 1; i >= 0; --i ) |
549 { |
512 { |
550 if ( !iObservers[i].iInitialEventDone ) |
513 if ( !iObservers[i].iInitialEventDone ) |
551 { |
514 { |
552 PROFILE_DEBUG3( "CSipAlrSnapMonitor::NotifyNewObservers", SnapId() ) |
515 PROFILE_DEBUG3( "CSipAlrSnapMonitor::NotifyNewObservers", iSnapId ) |
553 |
516 |
554 iObservers[i].iObserver->AlrEvent( |
517 iObservers[i].iObserver->AlrEvent( |
555 MSipAlrObserver::EIapAvailable, SnapId(), aIapId ); |
518 MSipAlrObserver::EIapAvailable, iSnapId, aIapId ); |
556 |
519 |
557 iObservers[i].iInitialEventDone = ETrue; |
520 iObservers[i].iInitialEventDone = ETrue; |
558 } |
521 } |
559 } |
522 } |
560 } |
523 } |
564 // ----------------------------------------------------------------------------- |
527 // ----------------------------------------------------------------------------- |
565 // |
528 // |
566 TBool CSipAlrSnapMonitor::IsSnapAvailable() const |
529 TBool CSipAlrSnapMonitor::IsSnapAvailable() const |
567 { |
530 { |
568 return ( iSystemStateMonitor.CurrentValue( |
531 return ( iSystemStateMonitor.CurrentValue( |
569 CSipSystemStateMonitor::ESnapAvailability, SnapId() ) == |
532 CSipSystemStateMonitor::ESnapAvailability, iSnapId ) == |
570 CSipSystemStateMonitor::ESnapAvailable ); |
533 CSipSystemStateMonitor::ESnapAvailable ); |
571 } |
534 } |
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // CSipAlrSnapMonitor::BearerId |
|
575 // ----------------------------------------------------------------------------- |
|
576 // |
|
577 TBool CSipAlrSnapMonitor::BearerId() |
|
578 { |
|
579 return iSnapData.iBearerId; |
|
580 } |
|