sipvoipprovider/src/svpemergencyconnection.cpp
changeset 2 7b872347d83b
parent 0 a4daefaec16c
equal deleted inserted replaced
1:bfb1de3eac8e 2:7b872347d83b
   193 // ---------------------------------------------------------------------------
   193 // ---------------------------------------------------------------------------
   194 //
   194 //
   195 void CSVPEmergencyConnection::RunL()
   195 void CSVPEmergencyConnection::RunL()
   196     {
   196     {
   197     TInt error = iStatus.Int();
   197     TInt error = iStatus.Int();
   198     SVPDEBUG2("CSVPEmergencyConnection::RunL(), error: %d", error)
   198     SVPDEBUG2( "CSVPEmergencyConnection::RunL(), error: %d", error )
   199     
   199     SVPDEBUG2( "CSVPEmergencyConnection::RunL(), Request type: %d", iRequestType )
   200     if ( error )
   200     
   201         {
   201     // execution goes to RunError() if error occured
   202         iRequestType = ESVPNone;
   202     User::LeaveIfError( iStatus.Int() );
   203         iObserver.ConnectionError( error );
       
   204         return;
       
   205         }
       
   206     
       
   207     switch ( iRequestType )
   203     switch ( iRequestType )
   208         {
   204         {
   209         case ESVPSnapConnect:
   205         case ESVPSnapConnect:
       
   206             SVPDEBUG1( "CSVPEmergencyConnection::RunL() - ESVPSnapConnect" )
   210             iRequestType = ESVPNone;
   207             iRequestType = ESVPNone;
   211             iObserver.SnapConnected();
   208             iObserver.SnapConnected();
   212             break;
   209             break;
   213         
   210         
   214         case ESVPConnect:
   211         case ESVPConnect:
       
   212             SVPDEBUG1( "CSVPEmergencyConnection::RunL() - ESVPConnect" )
   215             iRequestType = ESVPNone;
   213             iRequestType = ESVPNone;
   216             iObserver.Connected();
   214             iObserver.Connected();
   217             break;
   215             break;
   218             
   216             
   219         case ESVPSipProxyAddress:
   217         case ESVPSipProxyAddress:
   220             {
   218             {
       
   219             SVPDEBUG1( "CSVPEmergencyConnection::RunL() - ESVPSipProxyAddress" )
   221             iRequestType = ESVPNone;
   220             iRequestType = ESVPNone;
   222             
   221             
   223             // Copy SIP proxy address in dotted-decimal notation
   222             // Copy SIP proxy address in dotted-decimal notation
   224             HBufC16* sipProxyAddrBuf = HBufC16::NewLC( 39 ); // CS:1
   223             HBufC16* sipProxyAddrBuf = HBufC16::NewLC( 39 ); // CS:1
   225             TPtr16 sipProxyAddrPtr = sipProxyAddrBuf->Des();
   224             TPtr16 sipProxyAddrPtr = sipProxyAddrBuf->Des();
   226             iSipServerAddrBuf().address.Output( sipProxyAddrPtr );
   225             iSipServerAddrBuf().address.Output( sipProxyAddrPtr );
   227 
   226             SVPDEBUG2(
       
   227                     "CSVPEmergencyConnection::RunL(), iSipServerAddrBuf: %S",
       
   228                     sipProxyAddrBuf )
   228             // Call observer
   229             // Call observer
   229             iObserver.SipProxyAddressReady( *sipProxyAddrBuf );
   230             iObserver.SipProxyAddressReady( *sipProxyAddrBuf );
   230             CleanupStack::PopAndDestroy( sipProxyAddrBuf ); // CS:0
   231             CleanupStack::PopAndDestroy( sipProxyAddrBuf ); // CS:0
   231             break;
   232             break;
   232             }
   233             }
       
   234         case ESVPSipDomainAddress:
       
   235             {
       
   236             SVPDEBUG1( "CSVPEmergencyConnection::RunL() - ESVPSipDomainAddress" )
       
   237             iRequestType = ESVPNone;
       
   238             
       
   239             // Copy SIP proxy domain in dotted-decimal notation
       
   240             HBufC16* sipDomainAddrBuf = HBufC16::NewLC( iSipServerDomainBuf().domainName.Length() ); // CS:1
       
   241             TPtr16 sipDomainAddrPtr = sipDomainAddrBuf->Des();
       
   242             sipDomainAddrPtr.Copy( iSipServerDomainBuf().domainName );
       
   243             SVPDEBUG2(
       
   244                     "CSVPEmergencyConnection::RunL(), iSipDomainAddrBuf: %S",
       
   245                     sipDomainAddrBuf )
       
   246             // Call observer
       
   247             iObserver.SipProxyAddressReady( *sipDomainAddrBuf );
       
   248             CleanupStack::PopAndDestroy( sipDomainAddrBuf ); // CS:0
       
   249             break;
       
   250             }
   233             
   251             
   234         default:
   252         default:
       
   253             SVPDEBUG1( "CSVPEmergencyConnection::RunL() - Default" )
   235             iRequestType = ESVPNone;
   254             iRequestType = ESVPNone;
   236             iObserver.ConnectionError( KErrGeneral );
   255             iObserver.ConnectionError( KErrGeneral );
   237             break;
   256             break;
   238         }
   257         }
   239     }
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // CSVPEmergencyConnection::RunError
       
   262 //
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 TInt CSVPEmergencyConnection::RunError( TInt aError )
       
   266     {
       
   267     SVPDEBUG2( "CSVPEmergencyConnection::RunError() %d", aError )
       
   268     if ( iRequestType == ESVPSipProxyAddress )
       
   269         {
       
   270         /* 
       
   271          * sip proxy address might be NULL if requested with KConnGetSipServerAddr
       
   272          * and dhcp returns domain name to sip, instead of ipv4 or ipv6 type address.
       
   273          * So try once again with KConnGetSipServerDomain.
       
   274          */
       
   275         SVPDEBUG1( "CSVPEmergencyConnection::RunError() - RequestDomain" )
       
   276         RequestSipServerDomainL();    
       
   277         return KErrNone;
       
   278         }
       
   279     else
       
   280         {
       
   281         iRequestType = ESVPNone;
       
   282         SVPDEBUG2( "CSVPEmergencyConnection::RunError() - Notify Observer ConnectionError( %d )", aError )
       
   283         iObserver.ConnectionError( aError );
       
   284         return KErrNone;
       
   285         }
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // Requests for SIP proxy address
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 void CSVPEmergencyConnection::RequestSipServerDomainL()
       
   293     {
       
   294     SVPDEBUG1( 
       
   295         "CSVPEmergencyConnection::RequestSipServerDomainL() - Try to get Sip server domain" )
       
   296 
       
   297     if ( IsActive() )
       
   298         {
       
   299         User::Leave( KErrInUse );
       
   300         }
       
   301 
       
   302     iRequestType = ESVPSipDomainAddress;
       
   303     iSipServerDomainBuf().index = 0;
       
   304     // Request SIP server domain
       
   305     iConnection.Ioctl(
       
   306         KCOLConfiguration,
       
   307         KConnGetSipServerDomain, // domain in textual format
       
   308         iStatus,
       
   309         &iSipServerDomainBuf );
       
   310     SetActive();
       
   311     }