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