syncmlfw/common/syncagent/src/NSmlAgentBase.cpp
changeset 32 5d0ec111abfc
parent 24 bf47f3b79154
child 35 0deca9b72b62
equal deleted inserted replaced
27:2c8580950a26 32:5d0ec111abfc
    47 #endif
    47 #endif
    48 //Rnd_AutoRestart
    48 //Rnd_AutoRestart
    49 #include <es_sock.h> // RConnection RSocket
    49 #include <es_sock.h> // RConnection RSocket
    50 #include <es_enum.h> // TConnectionInfo
    50 #include <es_enum.h> // TConnectionInfo
    51 #include <commdb.h>
    51 #include <commdb.h>
    52 #include <ApListItemList.h>
    52 #include <cmconnectionmethoddef.h>
    53 #include <ApListItem.h>
    53 #include <cmconnectionmethod.h>
    54 #include <ApSelect.h>
    54 #include <cmmanager.h>
    55 #include <ApUtils.h>
    55 #include <cmpluginwlandef.h>
    56 #include "nsmlhttp.h"
    56 #include "nsmlhttp.h"
    57 
    57 
    58 //Fix to Remove the Bad Compiler Warnings
    58 //Fix to Remove the Bad Compiler Warnings
    59 #ifndef __WINS__
    59 #ifndef __WINS__
    60 // This lowers the unnecessary compiler warning (armv5) to remark.
    60 // This lowers the unnecessary compiler warning (armv5) to remark.
   448 	CleanupStack::PopAndDestroy();  //phoneInfo
   448 	CleanupStack::PopAndDestroy();  //phoneInfo
   449 	InitialiseSubStates();
   449 	InitialiseSubStates();
   450 	//Auto_Restart
   450 	//Auto_Restart
   451     iPacketDataUnAvailable = EFalse;    
   451     iPacketDataUnAvailable = EFalse;    
   452     iNetmonAPId = 0;
   452     iNetmonAPId = 0;
   453     iNetmonAPBearerType = TApBearerType(-1);
   453     iAllowAutoRestart = EFalse;
   454 	}
   454 	}
   455 
   455 
   456 
   456 
   457 //
   457 //
   458 // Beginning state functions 
   458 // Beginning state functions 
   955     				CleanupStack::PopAndDestroy(rep);
   955     				CleanupStack::PopAndDestroy(rep);
   956     				
   956     				
   957     				if(error == KErrNone && val == 1)
   957     				if(error == KErrNone && val == 1)
   958 					{
   958 					{
   959 		       		
   959 		       		
   960 			       		DBG_FILE_CODE(iNetmonAPBearerType, _S8("CNSmlAgentBase::SendingStateL The Network Bearer Type is"));
       
   961 			       		DBG_FILE_CODE(err, _S8("CNSmlAgentBase::SendingStateL The Network Error is"));
   960 			       		DBG_FILE_CODE(err, _S8("CNSmlAgentBase::SendingStateL The Network Error is"));
   962 			       		
   961 			       		
   963 			       		if(err == TNSmlHTTPErrCode::ENSmlHTTPErr_RequestTimeout)
   962 			       		if(err == TNSmlHTTPErrCode::ENSmlHTTPErr_RequestTimeout)
   964 			       		{
   963 			       		{
   965 			       			DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Invoking the NETMON exe due to Time Out"));
   964 			       			DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Invoking the NETMON exe due to Time Out"));
   968 		       				
   967 		       				
   969 			       			//Invoke the NetMon exe via the Agent
   968 			       			//Invoke the NetMon exe via the Agent
   970 			       			LaunchAutoRestartL(err);
   969 			       			LaunchAutoRestartL(err);
   971 			       		}
   970 			       		}
   972 		       		
   971 		       		
   973 			       		else if(iNetmonAPBearerType == EApBearerTypeGPRS ||
   972 			       		else if( iAllowAutoRestart )
   974 		    				   iNetmonAPBearerType == EApBearerTypeCDMA )
       
   975 			       		{
   973 			       		{
   976 			       			DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Waiting for 30 sec"));
   974 			       			DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Waiting for 30 sec"));
   977 			       			User::After(TTimeIntervalMicroSeconds32(30000000));
   975 			       			User::After(TTimeIntervalMicroSeconds32(30000000));
   978 			       			
   976 			       			
   979 			       			if(	iPacketDataUnAvailable )
   977 			       			if(	iPacketDataUnAvailable )
  1602 		TPckgBuf<TConnectionInfoV2> connectionInfo;
  1600 		TPckgBuf<TConnectionInfoV2> connectionInfo;
  1603 		err = myConnection.GetConnectionInfo( connectionCount,
  1601 		err = myConnection.GetConnectionInfo( connectionCount,
  1604 				connectionInfo );	
  1602 				connectionInfo );	
  1605 		iNetmonAPId = connectionInfo().iIapId;
  1603 		iNetmonAPId = connectionInfo().iIapId;
  1606 		DBG_FILE_CODE(iNetmonAPId, _S8("CNSmlAgentBase::ReadAcessPointL(), The IAPId is:"));
  1604 		DBG_FILE_CODE(iNetmonAPId, _S8("CNSmlAgentBase::ReadAcessPointL(), The IAPId is:"));
  1607 		iNetmonAPBearerType = CheckAPBearerTypeL( iNetmonAPId );
  1605 		RCmManager  cmmanager;
  1608 		DBG_FILE_CODE(TInt(iNetmonAPBearerType), _S8("CNSmlAgentBase::ReadAcessPointL(), The Enumerated IAPId is:"));
  1606 		cmmanager.OpenL();
  1609     	
  1607 		CleanupClosePushL(cmmanager);
  1610     }
  1608 		RCmConnectionMethod cm;
       
  1609 		cm = cmmanager.ConnectionMethodL( iNetmonAPId );
       
  1610 		CleanupClosePushL( cm );
       
  1611 		TUint32 bearer = 0;
       
  1612 		//TRAP_IGNORE( accesspointId = cm.GetIntAttributeL(CMManager::ECmIapId) );?
       
  1613 		bearer = cm.GetIntAttributeL( CMManager::ECmBearerType );
       
  1614 		CleanupStack::PopAndDestroy( 2 ); //cmmanager,cm
       
  1615 		if ( bearer == KUidWlanBearerType )
       
  1616 		{
       
  1617 			 iAllowAutoRestart = EFalse;
       
  1618 		}
       
  1619 		else
       
  1620 		{
       
  1621 			iAllowAutoRestart = ETrue;
       
  1622 		}
       
  1623 	}
  1611 
  1624 
  1612     myConnection.Close();
  1625     myConnection.Close();
  1613     socketServer.Close();
  1626     socketServer.Close();
  1614 }
       
  1615 
       
  1616 // -----------------------------------------------------------------------------
       
  1617 // CNSmlAgentBase::CheckAPBearerTypeL
       
  1618 // Returns bearer type of the selected Access Point.
       
  1619 // -----------------------------------------------------------------------------
       
  1620 EXPORT_C TApBearerType CNSmlAgentBase::CheckAPBearerTypeL( const TUint32 aIAPId )
       
  1621 {
       
  1622     // Create connection to the Access Points setting data.
       
  1623     CCommsDatabase* cAPCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
  1624     
       
  1625     TApBearerType bearerType(TApBearerType(-1));
       
  1626     
       
  1627     // Attach to the Access Point Engine.
       
  1628     CApSelect* apSelect = CApSelect::NewLC( 
       
  1629                                         *cAPCommsDatabase,
       
  1630                                         KEApIspTypeAll,
       
  1631                                             EApBearerTypeWLAN |
       
  1632                                             EApBearerTypeCDMA |
       
  1633                                             EApBearerTypeGPRS,
       
  1634                                         KEApSortUidAscending,
       
  1635                                         EIPv4 | EIPv6
       
  1636                                         );
       
  1637     
       
  1638     // Create ApUtils for some utilities functions.
       
  1639     CApUtils* apUtils = CApUtils::NewLC( *cAPCommsDatabase );
       
  1640     
       
  1641     // Get supported Access Points from Access Point Engine..
       
  1642     CApListItemList* apItems = new (ELeave) CApListItemList;
       
  1643     CleanupStack::PushL( apItems );
       
  1644     apSelect->AllListItemDataL( *apItems );
       
  1645     
       
  1646     for ( TInt i = 0; i < apItems->Count(); i++ )
       
  1647         {
       
  1648         // Get id from APEngine and convert it to the CommsDB id.
       
  1649         TUint32 iapId = apUtils->IapIdFromWapIdL( apItems->At( i )->Uid() );
       
  1650         
       
  1651         // Change bearer type according to id match.
       
  1652         if ( aIAPId == iapId )
       
  1653             {
       
  1654             bearerType = apItems->At( i )->BearerType(); 
       
  1655             
       
  1656             //Getting the IAP name
       
  1657             const TDesC& name = apItems->At( i )->Name();
       
  1658 		
       
  1659 			DBG_ARGS(_S("CNSmlAgentBase::CheckAPBearerTypeL(), The IAP Name is: %S"), &name);         
       
  1660                    
       
  1661             i = apItems->Count();
       
  1662             }
       
  1663         }
       
  1664     
       
  1665     // PopAndDestroy some items.
       
  1666     CleanupStack::PopAndDestroy( apItems );
       
  1667     CleanupStack::PopAndDestroy( apUtils );
       
  1668     CleanupStack::PopAndDestroy( apSelect );
       
  1669     
       
  1670     delete cAPCommsDatabase;
       
  1671     
       
  1672     // Return bearer type.
       
  1673     return bearerType;    
       
  1674 }
  1627 }
  1675 //RD_AUTO_RESTART
  1628 //RD_AUTO_RESTART
  1676 
  1629 
  1677 // ---------------------------------------------------------
  1630 // ---------------------------------------------------------
  1678 // CNSmlAgentBase::SendDataIssueL()
  1631 // CNSmlAgentBase::SendDataIssueL()