syncmlfw/common/syncagent/src/NSmlAgentBase.cpp
changeset 46 c15b68295419
parent 24 bf47f3b79154
child 35 0deca9b72b62
--- a/syncmlfw/common/syncagent/src/NSmlAgentBase.cpp	Sat May 01 10:33:10 2010 +0530
+++ b/syncmlfw/common/syncagent/src/NSmlAgentBase.cpp	Tue Jul 13 08:40:45 2010 +0530
@@ -49,10 +49,10 @@
 #include <es_sock.h> // RConnection RSocket
 #include <es_enum.h> // TConnectionInfo
 #include <commdb.h>
-#include <ApListItemList.h>
-#include <ApListItem.h>
-#include <ApSelect.h>
-#include <ApUtils.h>
+#include <cmconnectionmethoddef.h>
+#include <cmconnectionmethod.h>
+#include <cmmanager.h>
+#include <cmpluginwlandef.h>
 #include "nsmlhttp.h"
 
 //Fix to Remove the Bad Compiler Warnings
@@ -450,7 +450,7 @@
 	//Auto_Restart
     iPacketDataUnAvailable = EFalse;    
     iNetmonAPId = 0;
-    iNetmonAPBearerType = TApBearerType(-1);
+    iAllowAutoRestart = EFalse;
 	}
 
 
@@ -957,7 +957,6 @@
     				if(error == KErrNone && val == 1)
 					{
 		       		
-			       		DBG_FILE_CODE(iNetmonAPBearerType, _S8("CNSmlAgentBase::SendingStateL The Network Bearer Type is"));
 			       		DBG_FILE_CODE(err, _S8("CNSmlAgentBase::SendingStateL The Network Error is"));
 			       		
 			       		if(err == TNSmlHTTPErrCode::ENSmlHTTPErr_RequestTimeout)
@@ -970,8 +969,7 @@
 			       			LaunchAutoRestartL(err);
 			       		}
 		       		
-			       		else if(iNetmonAPBearerType == EApBearerTypeGPRS ||
-		    				   iNetmonAPBearerType == EApBearerTypeCDMA )
+			       		else if( iAllowAutoRestart )
 			       		{
 			       			DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Waiting for 30 sec"));
 			       			User::After(TTimeIntervalMicroSeconds32(30000000));
@@ -1604,74 +1602,29 @@
 				connectionInfo );	
 		iNetmonAPId = connectionInfo().iIapId;
 		DBG_FILE_CODE(iNetmonAPId, _S8("CNSmlAgentBase::ReadAcessPointL(), The IAPId is:"));
-		iNetmonAPBearerType = CheckAPBearerTypeL( iNetmonAPId );
-		DBG_FILE_CODE(TInt(iNetmonAPBearerType), _S8("CNSmlAgentBase::ReadAcessPointL(), The Enumerated IAPId is:"));
-    	
-    }
+		RCmManager  cmmanager;
+		cmmanager.OpenL();
+		CleanupClosePushL(cmmanager);
+		RCmConnectionMethod cm;
+		cm = cmmanager.ConnectionMethodL( iNetmonAPId );
+		CleanupClosePushL( cm );
+		TUint32 bearer = 0;
+		//TRAP_IGNORE( accesspointId = cm.GetIntAttributeL(CMManager::ECmIapId) );?
+		bearer = cm.GetIntAttributeL( CMManager::ECmBearerType );
+		CleanupStack::PopAndDestroy( 2 ); //cmmanager,cm
+		if ( bearer == KUidWlanBearerType )
+		{
+			 iAllowAutoRestart = EFalse;
+		}
+		else
+		{
+			iAllowAutoRestart = ETrue;
+		}
+	}
 
     myConnection.Close();
     socketServer.Close();
 }
-
-// -----------------------------------------------------------------------------
-// CNSmlAgentBase::CheckAPBearerTypeL
-// Returns bearer type of the selected Access Point.
-// -----------------------------------------------------------------------------
-EXPORT_C TApBearerType CNSmlAgentBase::CheckAPBearerTypeL( const TUint32 aIAPId )
-{
-    // Create connection to the Access Points setting data.
-    CCommsDatabase* cAPCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeIAP );
-    
-    TApBearerType bearerType(TApBearerType(-1));
-    
-    // Attach to the Access Point Engine.
-    CApSelect* apSelect = CApSelect::NewLC( 
-                                        *cAPCommsDatabase,
-                                        KEApIspTypeAll,
-                                            EApBearerTypeWLAN |
-                                            EApBearerTypeCDMA |
-                                            EApBearerTypeGPRS,
-                                        KEApSortUidAscending,
-                                        EIPv4 | EIPv6
-                                        );
-    
-    // Create ApUtils for some utilities functions.
-    CApUtils* apUtils = CApUtils::NewLC( *cAPCommsDatabase );
-    
-    // Get supported Access Points from Access Point Engine..
-    CApListItemList* apItems = new (ELeave) CApListItemList;
-    CleanupStack::PushL( apItems );
-    apSelect->AllListItemDataL( *apItems );
-    
-    for ( TInt i = 0; i < apItems->Count(); i++ )
-        {
-        // Get id from APEngine and convert it to the CommsDB id.
-        TUint32 iapId = apUtils->IapIdFromWapIdL( apItems->At( i )->Uid() );
-        
-        // Change bearer type according to id match.
-        if ( aIAPId == iapId )
-            {
-            bearerType = apItems->At( i )->BearerType(); 
-            
-            //Getting the IAP name
-            const TDesC& name = apItems->At( i )->Name();
-		
-			DBG_ARGS(_S("CNSmlAgentBase::CheckAPBearerTypeL(), The IAP Name is: %S"), &name);         
-                   
-            i = apItems->Count();
-            }
-        }
-    
-    // PopAndDestroy some items.
-    CleanupStack::PopAndDestroy( apItems );
-    CleanupStack::PopAndDestroy( apUtils );
-    CleanupStack::PopAndDestroy( apSelect );
-    
-    delete cAPCommsDatabase;
-    
-    // Return bearer type.
-    return bearerType;    
-}
 //RD_AUTO_RESTART
 
 // ---------------------------------------------------------