codhandler/codeng/src/Connection.cpp
branchRCL_3
changeset 58 220a17280356
parent 42 d39add9822e2
child 93 79859ed3eea9
--- a/codhandler/codeng/src/Connection.cpp	Fri Feb 19 23:55:03 2010 +0200
+++ b/codhandler/codeng/src/Connection.cpp	Fri Mar 12 15:48:51 2010 +0200
@@ -31,6 +31,13 @@
 #include <platform/mw/browser_platform_variant.hrh>
 #ifdef BRDO_OCC_ENABLED_FF
 #include <extendedconnpref.h>
+#include <FeatMgr.h>
+#include <CentralRepository.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
+#include <cmgenconnsettings.h>
+#include <cmmanagerkeys.h>
+#include <etelmm.h>
+#include <rconnmon.h>
 #endif
 
 // ================= MEMBER FUNCTIONS =======================
@@ -115,7 +122,25 @@
               extPref.SetSnapPurpose(CMManager::ESnapPurposeInternet);
 		   }
 
+           //Default dialog behaviour
            extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
+                  
+           if ( !IsPhoneOfflineL() )
+           {
+              TInt currentmode = KErrNone;
+              CRepository* rep = CRepository::NewLC( KCRUidCmManager );
+              rep->Get(KCurrentCellularDataUsage, currentmode );
+              CleanupStack::PopAndDestroy(); //rep
+              if(ECmCellularDataUsageConfirm == currentmode)
+              {
+                 if ( IsRoamingL() || (aIap == 0) )
+                 {
+                    CLOG(( EConn, 4, _L("Setting note behaviour as Default") ));
+                    extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
+                 }
+              }
+           }
+           
            TConnPrefList prefList;
            prefList.AppendL(&extPref);
            iConn.Start( prefList, iStatus );
@@ -343,3 +368,98 @@
     User::RequestComplete( iParentStatus, iStatus.Int() );
     iParentStatus = NULL;
     }
+
+#ifdef BRDO_OCC_ENABLED_FF
+// ---------------------------------------------------------
+// CConnection::IsPhoneOfflineL
+//
+// Checks if phone is in offline mode or not.
+// Return ETrue if phone is in offline mode.
+// Return EFalse if phone is not in offline mode.
+// ---------------------------------------------------------
+//
+TBool CConnection::IsPhoneOfflineL() const
+     {
+      if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
+         {
+         CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
+         TInt connAllowed = 1;
+         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
+         CleanupStack::PopAndDestroy();  // repository
+         if ( !connAllowed )
+             {
+             CLOG(( EConn, 2, _L("Yes, Phone is in Offline mode") ));
+             return ETrue;
+             }
+         }
+     
+     CLOG(( EConn, 2, _L("Phone is in Online mode") ));
+     return EFalse;
+     }
+
+// ---------------------------------------------------------
+// CConnection::IsRoamingL
+//
+// Checks if phone is in home network or in roam network.
+// Return ETrue if phone is in foriegn network.
+// Return EFalse if phone is in home network.
+// ---------------------------------------------------------
+//
+TBool CConnection::IsRoamingL()
+    {
+        RTelServer telServer;
+        User::LeaveIfError( telServer.Connect());
+        
+        RTelServer::TPhoneInfo teleinfo;
+        User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
+        
+        RMobilePhone phone;
+        User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
+        User::LeaveIfError(phone.Initialise()); 
+        
+        RMobilePhone::TMobilePhoneNetworkMode mode;                     
+        TInt err = phone.GetCurrentMode( mode );
+        phone.Close();
+        telServer.Close();
+        TInt Bearer = EBearerIdGSM ;
+        if( KErrNone == err )
+        {
+           switch(mode)
+           {
+                case RMobilePhone::ENetworkModeGsm:     
+                {           
+                Bearer = EBearerIdGSM ;
+                    break;      
+                }
+                case RMobilePhone::ENetworkModeWcdma:
+                {                                   
+                    Bearer = EBearerIdWCDMA  ;
+                    break;  
+                }   
+                default: 
+                {                   
+                
+                }                       
+            }
+        }   
+        RConnectionMonitor monitor;
+        TRequestStatus status;
+        // open RConnectionMonitor object
+        monitor.ConnectL();
+        CleanupClosePushL( monitor );
+        TInt netwStatus ;
+        monitor.GetIntAttribute( Bearer, 0, KNetworkRegistration, netwStatus, status );
+        User::WaitForRequest( status );
+        CleanupStack::PopAndDestroy(); // Destroying monitor
+        if ( status.Int() == KErrNone && netwStatus == ENetworkRegistrationRoaming )
+        {
+            CLOG(( EConn, 2, _L("Yes, Phone is in Forign network") ));
+            return ETrue;
+        }
+        else //home n/w or some other state in n/w
+        {
+            CLOG(( EConn, 2, _L("Phone is in Home network") ));
+            return EFalse;
+        }
+   }
+#endif