378 // |
384 // |
379 // --------------------------------------------------------- |
385 // --------------------------------------------------------- |
380 void CNSmlDialUpAgent::DoSettingsL() |
386 void CNSmlDialUpAgent::DoSettingsL() |
381 { |
387 { |
382 DBG_FILE( _S8("CNSmlDialUpAgent::DoSettingsL") ); |
388 DBG_FILE( _S8("CNSmlDialUpAgent::DoSettingsL") ); |
383 iOffline=IsInOfflineModeL(); |
389 iOffline=IsInOfflineModeL(); |
384 iExtPrefs.SetForcedRoaming(EFalse); |
390 if( static_cast<TInt32>(iIAPid) == -1 ) |
385 if( ( static_cast<TInt32>(iIAPid) == -2 ) || |
391 { |
386 static_cast<TInt32>(iIAPid) == -1 ) // default connection |
392 if(iOffline) |
387 { |
393 { |
388 TBool Snap = EFalse; |
394 iPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
389 RCmManager cmmgr; |
395 iPref.SetBearerSet(KUidWlanBearerType); |
390 cmmgr.OpenL(); |
|
391 TCmDefConnValue defConnValue; |
|
392 cmmgr.ReadDefConnL(defConnValue); |
|
393 cmmgr.Close(); |
|
394 if(defConnValue.iType == ECmDefConnDestination) |
|
395 { |
|
396 iExtPrefs.SetSnapId(defConnValue.iId); |
|
397 Snap = ETrue; |
|
398 } |
396 } |
399 else if(defConnValue.iType == ECmDefConnConnectionMethod) |
397 else |
400 { |
398 { |
401 iExtPrefs.SetIapId(defConnValue.iId); |
399 iPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
402 } |
400 //iPref.SetBearerSet(EApBearerTypeAllBearers); |
403 iExtPrefs.SetConnSelectionDialog(EFalse); |
401 } |
404 if(iDmjob) |
402 } |
405 { |
403 else if( iOffline && ( static_cast<TInt32>(iIAPid) == -2 ) ) // default connection |
406 TInt val = KErrNotFound; |
404 { |
407 TInt r2=RProperty::Get(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob,val); |
405 iPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
408 DBG_FILE_CODE( r2, _S8("CNSmlDialUpAgent::DoSettingsL dc KNSmlDMSilentJob set error code") ); |
406 iPref.SetBearerSet(KUidWlanBearerType); |
409 if(val == ESilent) //silent session |
|
410 { |
|
411 //Check the cenrep key |
|
412 TInt currentmode = KErrNone; |
|
413 CRepository* rep = CRepository::NewLC( KCRUidCmManager ); |
|
414 rep->Get(KCurrentCellularDataUsage, currentmode ); |
|
415 CleanupStack::PopAndDestroy(); //rep |
|
416 //if "Always ask", check the roam or home |
|
417 // if snap dont allow silent connections at all in"always ask" |
|
418 if(Snap)//Check also for roaming n/w IAP as d.c case |
|
419 { |
|
420 //Check the general settings |
|
421 if(ECmCellularDataUsageConfirm == currentmode) |
|
422 { |
|
423 //As silent session fails in roam or home with snap, then dont go for silent sessions . |
|
424 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault ); |
|
425 } |
|
426 else |
|
427 { |
|
428 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent ); |
|
429 } |
|
430 } |
|
431 else //IAP as d.c |
|
432 { |
|
433 |
|
434 //dont set any preference, as this leads to fail |
|
435 //else //home n/w or roam n/w with automatic or WLAN only |
|
436 TBool roaming = EFalse; |
|
437 IsRoamingL(roaming); |
|
438 if(ECmCellularDataUsageConfirm == currentmode && roaming) |
|
439 { |
|
440 //No silent connection preference, as this leads to failure of connection |
|
441 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault ); |
|
442 } |
|
443 else |
|
444 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent ); |
|
445 } |
|
446 RProperty::Set(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob,KErrNone); |
|
447 } |
|
448 } |
|
449 } |
407 } |
450 else |
408 else |
451 { |
409 { |
452 iExtPrefs.SetIapId(iIAPid); |
410 iPref.SetIapId( iIAPid ); |
453 iExtPrefs.SetConnSelectionDialog(EFalse); |
411 iPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
454 if(iDmjob) |
412 } |
455 { |
|
456 TInt val = KErrNotFound; |
|
457 TInt r2=RProperty::Get(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob,val); |
|
458 DBG_FILE_CODE( r2, _S8("CNSmlDialUpAgent::DoSettingsL IAP KNSmlDMSilentJob set error code") ); |
|
459 if(val == ESilent) //silent session |
|
460 { |
|
461 //Check the cenrep key |
|
462 TInt currentmode = KErrNone; |
|
463 CRepository* rep = CRepository::NewLC( KCRUidCmManager ); |
|
464 rep->Get(KCurrentCellularDataUsage, currentmode ); |
|
465 CleanupStack::PopAndDestroy(); //rep |
|
466 TBool roaming = EFalse; |
|
467 IsRoamingL(roaming); |
|
468 if(ECmCellularDataUsageConfirm == currentmode && roaming ) |
|
469 { |
|
470 //As silent session fails in roam or home with snap, then dont go for silent sessions . |
|
471 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault ); |
|
472 } |
|
473 else |
|
474 { |
|
475 iExtPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent ); |
|
476 } |
|
477 } |
|
478 } |
|
479 RProperty::Set(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob,KErrNone); |
|
480 } |
|
481 iPrefList.AppendL(&iExtPrefs); |
|
482 |
|
483 } |
413 } |
484 //---------------------------------------------------------- |
414 //---------------------------------------------------------- |
485 //CNsmlDialUpAgent::IsOfflineModeL() |
415 //CNsmlDialUpAgent::IsOfflineModeL() |
486 //------------------------------------------------------------ |
|
487 TBool CNSmlDialUpAgent::IsInOfflineModeL() |
416 TBool CNSmlDialUpAgent::IsInOfflineModeL() |
488 { |
417 { |
489 TInt operationsAllowed( ECoreAppUIsNetworkConnectionAllowed ); |
418 TInt operationsAllowed( ECoreAppUIsNetworkConnectionAllowed ); |
490 CRepository* rep = CRepository::NewLC( KCRUidCoreApplicationUIs ); |
419 CRepository* rep = CRepository::NewLC( KCRUidCoreApplicationUIs ); |
491 rep->Get(KCoreAppUIsNetworkConnectionAllowed, operationsAllowed ); |
420 rep->Get(KCoreAppUIsNetworkConnectionAllowed, operationsAllowed ); |
492 CleanupStack::PopAndDestroy(); //rep |
421 CleanupStack::PopAndDestroy(); //rep |
493 |
422 |
494 return ( operationsAllowed == ECoreAppUIsNetworkConnectionNotAllowed ) ? ETrue : EFalse; |
423 return ( operationsAllowed == ECoreAppUIsNetworkConnectionNotAllowed ) ? ETrue : EFalse; |
495 } |
424 } |
496 |
|
497 //------------------------------------------------------------ |
|
498 // CNSmlDialUpAgent::IsRoamingL() |
|
499 // Returns roaming network or not |
|
500 //------------------------------------------------------------ |
|
501 void CNSmlDialUpAgent::IsRoamingL( TBool& aRoaming) |
|
502 { |
|
503 RTelServer telServer; |
|
504 User::LeaveIfError( telServer.Connect()); |
|
505 |
|
506 RTelServer::TPhoneInfo teleinfo; |
|
507 User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) ); |
|
508 |
|
509 RMobilePhone phone; |
|
510 User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) ); |
|
511 |
|
512 User::LeaveIfError(phone.Initialise()); |
|
513 |
|
514 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
515 TInt err = phone.GetCurrentMode( mode ); |
|
516 phone.Close(); |
|
517 telServer.Close(); |
|
518 TInt Bearer = EBearerIdGSM ; |
|
519 if( KErrNone == err ) |
|
520 { |
|
521 switch(mode) |
|
522 { |
|
523 case RMobilePhone::ENetworkModeGsm: |
|
524 { |
|
525 Bearer = EBearerIdGSM; |
|
526 break; |
|
527 } |
|
528 case RMobilePhone::ENetworkModeWcdma: |
|
529 { |
|
530 Bearer = EBearerIdWCDMA ; |
|
531 } |
|
532 default: |
|
533 { |
|
534 break; |
|
535 } |
|
536 } |
|
537 } |
|
538 RConnectionMonitor monitor; |
|
539 TRequestStatus status; |
|
540 // open RConnectionMonitor object |
|
541 monitor.ConnectL(); |
|
542 CleanupClosePushL( monitor ); |
|
543 TInt netwStatus(0); |
|
544 monitor.GetIntAttribute( Bearer, |
|
545 0, |
|
546 KNetworkRegistration, |
|
547 netwStatus, |
|
548 status ); |
|
549 User::WaitForRequest( status ); |
|
550 CleanupStack::PopAndDestroy(); // Destroying monitor |
|
551 if ( status.Int() == KErrNone && netwStatus == ENetworkRegistrationRoaming ) |
|
552 { |
|
553 aRoaming = ETrue; |
|
554 } |
|
555 else //home n/w or some other state in n/w |
|
556 { |
|
557 aRoaming = EFalse; |
|
558 } |
|
559 } |
|