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