diff -r 5886d40bb3de -r 2989b291cac7 voipplugins/sipconnectionprovider/src/scpvoiphandler.cpp --- a/voipplugins/sipconnectionprovider/src/scpvoiphandler.cpp Wed Sep 15 12:01:56 2010 +0300 +++ b/voipplugins/sipconnectionprovider/src/scpvoiphandler.cpp Wed Oct 13 14:20:32 2010 +0300 @@ -17,6 +17,7 @@ #include +#include #include #include "scpvoiphandler.h" #include "scpprofilehandler.h" @@ -26,6 +27,7 @@ #include "scpsettinghandler.h" #include "scpsipconnection.h" #include "scputility.h" +#include "scppropertynotifier.h" #include "csipclientresolverutils.h" // : These need to be in some common header @@ -51,6 +53,8 @@ SCPLOGSTRING2( "CScpVoipHandler[0x%x]::ConstructL", this ); BaseConstructL(); + iNetworkMode = CScpPropertyNotifier::NewL( KPSUidNetworkInfo, + KNWTelephonyNetworkMode, *this ) ; iSipClientResolver = CSipClientResolverUtils::NewL(); } @@ -78,6 +82,7 @@ { SCPLOGSTRING2( "CScpVoipHandler[0x%x]::~CScpVoipHandler", this ); delete iSipClientResolver; + delete iNetworkMode; } // ----------------------------------------------------------------------------- @@ -193,11 +198,13 @@ TScpConnectionEvent aEvent ) { SCPLOGSTRING4( "CScpVoipHandler[0x%x]::HandleSipConnectionEvent id: %d event: %d", - this, aProfileId, aEvent ); + this, aProfileId, aEvent ); if( iSubService.SipProfileId() == aProfileId && iSubService.EnableRequestedState() != CScpSubService::EScpNoRequest ) { + // When in 2G mode with GPRS iap we are enabled but can't + // create or receive any VoIP calls if( aEvent == EScpRegistered && iSubService.EnableRequestedState() == CScpSubService::EScpEnabled ) { @@ -205,11 +212,40 @@ contactHeaderUser.CleanupClosePushL(); GetSipProfileContactHeaderUserL( contactHeaderUser ); - SCPLOGSTRING( "HandleSipConnectionEventL -> register client" ); + HBufC* string = HBufC::NewLC(contactHeaderUser.Length()); + string->Des().Copy(contactHeaderUser); + + SCPLOGSTRING2( "CScpVoipHandler::HandleSipConnectionEventL(), contactHeaderUser %S", string ); - iSipClientResolver->RegisterClientWithUserL( - GetCallProviderImplementationUidL(), contactHeaderUser, KResolver ); - + CleanupStack::PopAndDestroy(string); + + TInt networkMode = KErrNotFound; + TInt result = iNetworkMode->GetValue( networkMode ); + + if( result == KErrNone && + networkMode == ENWNetworkModeGsm && + iSubService.GetIapType() == EScpGprs ) + { + aEvent = EScpBandwidthLimited; + iSipClientResolver->UnRegisterClientWithUserL( + GetCallProviderImplementationUidL(), contactHeaderUser ); + } + else if ( KErrNone == result && + EScpGprs == iSubService.GetIapType() && + !iSubService.ServiceStorage().SettingsHandler().IsVoIPOverWcdmaAllowedL( iSubService.SubServiceId() ) ) + { + aEvent = EScpBearerNotSupported; + SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), VoIP over 3G not allowed" ); + iSipClientResolver->UnRegisterClientWithUserL( + GetCallProviderImplementationUidL(), contactHeaderUser ); + } + else + { + iSipClientResolver->RegisterClientWithUserL( + GetCallProviderImplementationUidL(), contactHeaderUser, KResolver ); + SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), client resolver" ); + } + CleanupStack::PopAndDestroy( &contactHeaderUser ); }