23 #include "Connection.h" |
23 #include "Connection.h" |
24 #include "CodPanic.h" |
24 #include "CodPanic.h" |
25 #include "CodUtil.h" |
25 #include "CodUtil.h" |
26 #include "CodError.h" |
26 #include "CodError.h" |
27 #include "CodLogger.h" |
27 #include "CodLogger.h" |
28 #include <CommDbConnPref.h> |
28 #include <commdbconnpref.h> |
29 #include <cdblen.h> |
29 #include <cdblen.h> |
30 #include <es_enum.h> |
30 #include <es_enum.h> |
31 #include <platform/mw/browser_platform_variant.hrh> |
|
32 #ifdef BRDO_OCC_ENABLED_FF |
|
33 #include <extendedconnpref.h> |
|
34 #include <FeatMgr.h> |
|
35 #include <CentralRepository.h> |
|
36 #include <CoreApplicationUIsSDKCRKeys.h> |
|
37 #include <cmgenconnsettings.h> |
|
38 #include <cmmanagerkeys.h> |
|
39 #include <etelmm.h> |
|
40 #include <rconnmon.h> |
|
41 #endif |
|
42 |
31 |
43 // ================= MEMBER FUNCTIONS ======================= |
32 // ================= MEMBER FUNCTIONS ======================= |
44 |
33 |
45 // --------------------------------------------------------- |
34 // --------------------------------------------------------- |
46 // CConnection::NewL() |
35 // CConnection::NewL() |
103 else |
92 else |
104 { |
93 { |
105 // aIap == 0 -> user select. |
94 // aIap == 0 -> user select. |
106 iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
95 iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt ); |
107 } |
96 } |
108 #ifdef BRDO_OCC_ENABLED_FF |
97 iConn.Start( iConnPref, iStatus ); |
109 TExtendedConnPref extPref; |
|
110 CLOG(( EConn, 4, _L("CodHalder Setting OCC parameters") )); |
|
111 |
|
112 CLOG(( EConn, 4, _L("Iap: %d"), aIap )); |
|
113 if (aIap) |
|
114 { |
|
115 CLOG(( EConn, 4, _L("Iap is found") )); |
|
116 extPref.SetSnapPurpose(CMManager::ESnapPurposeUnknown); |
|
117 extPref.SetIapId(aIap); |
|
118 } |
|
119 else |
|
120 { |
|
121 CLOG(( EConn, 4, _L("Using Internet Snap") )); |
|
122 extPref.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
|
123 } |
|
124 |
|
125 //Default dialog behaviour |
|
126 extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); |
|
127 |
|
128 if ( !IsPhoneOfflineL() ) |
|
129 { |
|
130 TInt currentmode = KErrNone; |
|
131 CRepository* rep = CRepository::NewLC( KCRUidCmManager ); |
|
132 rep->Get(KCurrentCellularDataUsage, currentmode ); |
|
133 CleanupStack::PopAndDestroy(); //rep |
|
134 if(ECmCellularDataUsageConfirm == currentmode) |
|
135 { |
|
136 if ( IsRoamingL() || (aIap == 0) ) |
|
137 { |
|
138 CLOG(( EConn, 4, _L("Setting note behaviour as Default") )); |
|
139 extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 TConnPrefList prefList; |
|
145 prefList.AppendL(&extPref); |
|
146 iConn.Start( prefList, iStatus ); |
|
147 #else |
|
148 iConn.Start( iConnPref, iStatus ); |
|
149 #endif //BRDO_OCC_ENABLED_FF |
|
150 |
|
151 iState = EConnecting; |
98 iState = EConnecting; |
152 SetActive(); |
99 SetActive(); |
153 CleanupStack::Pop( 2 ); // closing iConn and iSockServ |
100 CleanupStack::Pop( 2 ); // closing iConn and iSockServ |
154 // End of atomic part. |
101 // End of atomic part. |
155 } |
102 } |
366 CLOG(( EConn, 2, _L("CConnection::Done iStatus(%d)"), iStatus.Int() )); |
313 CLOG(( EConn, 2, _L("CConnection::Done iStatus(%d)"), iStatus.Int() )); |
367 __ASSERT_DEBUG( iParentStatus, CodPanic( ECodInternal ) ); |
314 __ASSERT_DEBUG( iParentStatus, CodPanic( ECodInternal ) ); |
368 User::RequestComplete( iParentStatus, iStatus.Int() ); |
315 User::RequestComplete( iParentStatus, iStatus.Int() ); |
369 iParentStatus = NULL; |
316 iParentStatus = NULL; |
370 } |
317 } |
371 |
|
372 #ifdef BRDO_OCC_ENABLED_FF |
|
373 // --------------------------------------------------------- |
|
374 // CConnection::IsPhoneOfflineL |
|
375 // |
|
376 // Checks if phone is in offline mode or not. |
|
377 // Return ETrue if phone is in offline mode. |
|
378 // Return EFalse if phone is not in offline mode. |
|
379 // --------------------------------------------------------- |
|
380 // |
|
381 TBool CConnection::IsPhoneOfflineL() const |
|
382 { |
|
383 if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) |
|
384 { |
|
385 CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs ); |
|
386 TInt connAllowed = 1; |
|
387 repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed ); |
|
388 CleanupStack::PopAndDestroy(); // repository |
|
389 if ( !connAllowed ) |
|
390 { |
|
391 CLOG(( EConn, 2, _L("Yes, Phone is in Offline mode") )); |
|
392 return ETrue; |
|
393 } |
|
394 } |
|
395 |
|
396 CLOG(( EConn, 2, _L("Phone is in Online mode") )); |
|
397 return EFalse; |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // CConnection::IsRoamingL |
|
402 // |
|
403 // Checks if phone is in home network or in roam network. |
|
404 // Return ETrue if phone is in foriegn network. |
|
405 // Return EFalse if phone is in home network. |
|
406 // --------------------------------------------------------- |
|
407 // |
|
408 TBool CConnection::IsRoamingL() |
|
409 { |
|
410 RTelServer telServer; |
|
411 User::LeaveIfError( telServer.Connect()); |
|
412 |
|
413 RTelServer::TPhoneInfo teleinfo; |
|
414 User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) ); |
|
415 |
|
416 RMobilePhone phone; |
|
417 User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) ); |
|
418 User::LeaveIfError(phone.Initialise()); |
|
419 |
|
420 RMobilePhone::TMobilePhoneNetworkMode mode; |
|
421 TInt err = phone.GetCurrentMode( mode ); |
|
422 phone.Close(); |
|
423 telServer.Close(); |
|
424 TInt Bearer = EBearerIdGSM ; |
|
425 if( KErrNone == err ) |
|
426 { |
|
427 switch(mode) |
|
428 { |
|
429 case RMobilePhone::ENetworkModeGsm: |
|
430 { |
|
431 Bearer = EBearerIdGSM ; |
|
432 break; |
|
433 } |
|
434 case RMobilePhone::ENetworkModeWcdma: |
|
435 { |
|
436 Bearer = EBearerIdWCDMA ; |
|
437 break; |
|
438 } |
|
439 default: |
|
440 { |
|
441 |
|
442 } |
|
443 } |
|
444 } |
|
445 RConnectionMonitor monitor; |
|
446 TRequestStatus status; |
|
447 // open RConnectionMonitor object |
|
448 monitor.ConnectL(); |
|
449 CleanupClosePushL( monitor ); |
|
450 TInt netwStatus ; |
|
451 monitor.GetIntAttribute( Bearer, 0, KNetworkRegistration, netwStatus, status ); |
|
452 User::WaitForRequest( status ); |
|
453 CleanupStack::PopAndDestroy(); // Destroying monitor |
|
454 if ( status.Int() == KErrNone && netwStatus == ENetworkRegistrationRoaming ) |
|
455 { |
|
456 CLOG(( EConn, 2, _L("Yes, Phone is in Forign network") )); |
|
457 return ETrue; |
|
458 } |
|
459 else //home n/w or some other state in n/w |
|
460 { |
|
461 CLOG(( EConn, 2, _L("Phone is in Home network") )); |
|
462 return EFalse; |
|
463 } |
|
464 } |
|
465 #endif |
|