voipplugins/sipconnectionprovider/src/scpvoiphandler.cpp
branchRCL_3
changeset 33 2989b291cac7
parent 28 d38647835c2e
equal deleted inserted replaced
31:5886d40bb3de 33:2989b291cac7
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32property.h>
    19 #include <e32property.h>
       
    20 #include <networkhandlingdomainpskeys.h>
    20 #include <spdefinitions.h>
    21 #include <spdefinitions.h>
    21 #include "scpvoiphandler.h"
    22 #include "scpvoiphandler.h"
    22 #include "scpprofilehandler.h"
    23 #include "scpprofilehandler.h"
    23 #include "scplogger.h"
    24 #include "scplogger.h"
    24 #include "scpsubservice.h"
    25 #include "scpsubservice.h"
    25 #include "scpservicestorage.h"
    26 #include "scpservicestorage.h"
    26 #include "scpsettinghandler.h"
    27 #include "scpsettinghandler.h"
    27 #include "scpsipconnection.h"
    28 #include "scpsipconnection.h"
    28 #include "scputility.h"
    29 #include "scputility.h"
       
    30 #include "scppropertynotifier.h"
    29 #include "csipclientresolverutils.h"
    31 #include "csipclientresolverutils.h"
    30 
    32 
    31 // : These need to be in some common header
    33 // : These need to be in some common header
    32 const TUid KResolver = { 0x10283140 };
    34 const TUid KResolver = { 0x10283140 };
    33 
    35 
    49 void CScpVoipHandler::ConstructL()
    51 void CScpVoipHandler::ConstructL()
    50     {
    52     {
    51     SCPLOGSTRING2( "CScpVoipHandler[0x%x]::ConstructL", this );
    53     SCPLOGSTRING2( "CScpVoipHandler[0x%x]::ConstructL", this );
    52     
    54     
    53     BaseConstructL();
    55     BaseConstructL();
       
    56     iNetworkMode = CScpPropertyNotifier::NewL( KPSUidNetworkInfo, 
       
    57         KNWTelephonyNetworkMode, *this ) ;
    54     iSipClientResolver = CSipClientResolverUtils::NewL();
    58     iSipClientResolver = CSipClientResolverUtils::NewL();
    55     }
    59     }
    56 
    60 
    57 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    58 // CScpVoipHandler::NewL
    62 // CScpVoipHandler::NewL
    76 //
    80 //
    77 CScpVoipHandler::~CScpVoipHandler()
    81 CScpVoipHandler::~CScpVoipHandler()
    78     {
    82     {
    79     SCPLOGSTRING2( "CScpVoipHandler[0x%x]::~CScpVoipHandler", this );
    83     SCPLOGSTRING2( "CScpVoipHandler[0x%x]::~CScpVoipHandler", this );
    80     delete iSipClientResolver;
    84     delete iSipClientResolver;
       
    85     delete iNetworkMode;
    81     }
    86     }
    82 
    87 
    83 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    84 // CScpVoipHandler::HandlePropertyChanged
    89 // CScpVoipHandler::HandlePropertyChanged
    85 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   191 //
   196 //
   192 void CScpVoipHandler::HandleSipConnectionEventL( TUint32 aProfileId,
   197 void CScpVoipHandler::HandleSipConnectionEventL( TUint32 aProfileId,
   193                                                 TScpConnectionEvent aEvent )
   198                                                 TScpConnectionEvent aEvent )
   194     {
   199     {
   195     SCPLOGSTRING4( "CScpVoipHandler[0x%x]::HandleSipConnectionEvent id: %d event: %d",
   200     SCPLOGSTRING4( "CScpVoipHandler[0x%x]::HandleSipConnectionEvent id: %d event: %d",
   196         this, aProfileId, aEvent );
   201                    this, aProfileId, aEvent );
   197 
   202 
   198     if( iSubService.SipProfileId() == aProfileId &&
   203     if( iSubService.SipProfileId() == aProfileId &&
   199         iSubService.EnableRequestedState() != CScpSubService::EScpNoRequest )
   204         iSubService.EnableRequestedState() != CScpSubService::EScpNoRequest )
   200         {
   205         {
       
   206         // When in 2G mode with GPRS iap we are enabled but can't
       
   207         // create or receive any VoIP calls
   201         if( aEvent == EScpRegistered &&
   208         if( aEvent == EScpRegistered &&
   202             iSubService.EnableRequestedState() == CScpSubService::EScpEnabled )
   209             iSubService.EnableRequestedState() == CScpSubService::EScpEnabled )
   203             {
   210             {
   204             RBuf8 contactHeaderUser;
   211             RBuf8 contactHeaderUser;
   205             contactHeaderUser.CleanupClosePushL();
   212             contactHeaderUser.CleanupClosePushL();
   206             GetSipProfileContactHeaderUserL( contactHeaderUser );
   213             GetSipProfileContactHeaderUserL( contactHeaderUser );
   207             
   214             
   208             SCPLOGSTRING( "HandleSipConnectionEventL -> register client" );
   215             HBufC* string = HBufC::NewLC(contactHeaderUser.Length());
       
   216             string->Des().Copy(contactHeaderUser);
       
   217          
       
   218             SCPLOGSTRING2( "CScpVoipHandler::HandleSipConnectionEventL(), contactHeaderUser %S", string );
   209             
   219             
   210             iSipClientResolver->RegisterClientWithUserL( 
   220             CleanupStack::PopAndDestroy(string);
   211                 GetCallProviderImplementationUidL(), contactHeaderUser, KResolver );
   221 
   212             
   222             TInt networkMode = KErrNotFound;
       
   223             TInt result = iNetworkMode->GetValue( networkMode );
       
   224 
       
   225             if( result == KErrNone &&
       
   226                 networkMode == ENWNetworkModeGsm &&
       
   227                 iSubService.GetIapType() == EScpGprs )
       
   228                 {
       
   229                 aEvent = EScpBandwidthLimited;    
       
   230                 iSipClientResolver->UnRegisterClientWithUserL( 
       
   231                     GetCallProviderImplementationUidL(), contactHeaderUser );
       
   232                 }
       
   233             else if ( KErrNone == result &&
       
   234                 EScpGprs == iSubService.GetIapType() &&
       
   235                 !iSubService.ServiceStorage().SettingsHandler().IsVoIPOverWcdmaAllowedL( iSubService.SubServiceId() ) )
       
   236                 {
       
   237                 aEvent = EScpBearerNotSupported;
       
   238                 SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), VoIP over 3G not allowed" );
       
   239                 iSipClientResolver->UnRegisterClientWithUserL( 
       
   240                     GetCallProviderImplementationUidL(), contactHeaderUser );
       
   241                 }
       
   242             else
       
   243                 {
       
   244                 iSipClientResolver->RegisterClientWithUserL( 
       
   245                     GetCallProviderImplementationUidL(), contactHeaderUser, KResolver );
       
   246                 SCPLOGSTRING( "CScpVoipHandler::HandleSipConnectionEventL(), client resolver" );
       
   247                 }
       
   248 
   213             CleanupStack::PopAndDestroy( &contactHeaderUser );
   249             CleanupStack::PopAndDestroy( &contactHeaderUser );
   214             }
   250             }
   215 
   251 
   216         iSubService.HandleConnectionEvent( aEvent );
   252         iSubService.HandleConnectionEvent( aEvent );
   217         }
   253         }