diff -r b183ec05bd8c -r 19bba8228ff0 syncmlfw/common/syncagent/src/NSmlAgentBase.cpp --- a/syncmlfw/common/syncagent/src/NSmlAgentBase.cpp Tue Aug 31 16:04:06 2010 +0300 +++ b/syncmlfw/common/syncagent/src/NSmlAgentBase.cpp Wed Sep 01 12:27:42 2010 +0100 @@ -50,10 +50,10 @@ #include // RConnection RSocket #include // TConnectionInfo #include -#include -#include -#include -#include +#include +#include +#include +#include #include "nsmlhttp.h" //Fix to Remove the Bad Compiler Warnings @@ -451,7 +451,7 @@ //Auto_Restart iPacketDataUnAvailable = EFalse; iNetmonAPId = 0; - iAllowAutoRestart = EFalse; + iNetmonAPBearerType = TApBearerType(-1); } @@ -958,6 +958,7 @@ 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,7 +971,8 @@ LaunchAutoRestartL(err); } - else if( iAllowAutoRestart ) + else if(iNetmonAPBearerType == EApBearerTypeGPRS || + iNetmonAPBearerType == EApBearerTypeCDMA ) { DBG_FILE(_S8("CNSmlAgentBase::SendingStateL Waiting for 30 sec")); User::After(TTimeIntervalMicroSeconds32(30000000)); @@ -1603,29 +1605,74 @@ connectionInfo ); iNetmonAPId = connectionInfo().iIapId; DBG_FILE_CODE(iNetmonAPId, _S8("CNSmlAgentBase::ReadAcessPointL(), The 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; - } - } + iNetmonAPBearerType = CheckAPBearerTypeL( iNetmonAPId ); + DBG_FILE_CODE(TInt(iNetmonAPBearerType), _S8("CNSmlAgentBase::ReadAcessPointL(), The Enumerated IAPId is:")); + + } 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 // --------------------------------------------------------- @@ -1918,7 +1965,10 @@ if(iPacketDataUnAvailable) { DBG_FILE(_S8("CNSmlAgentBase::FinaliseWhenErrorL Prompting for a Dialog")); - iError->SetErrorCode( TNSmlError::ESmlCommunicationError); + if (iError) + { + iError->SetErrorCode( TNSmlError::ESmlCommunicationError); + } User::RequestComplete( iCallerStatus, TNSmlError::ESmlCommunicationError ); } //RD_AUTO_RESTART