hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp
changeset 13 33016869e0dd
parent 0 a03f92240627
equal deleted inserted replaced
0:a03f92240627 13:33016869e0dd
    17 
    17 
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include "CIPProxyEngine.h"
    21 #include "CIPProxyEngine.h"
    22 #include "CTCPPortListener.h"
    22 #include "Ctcpportlistener.h"
    23 #include "CLocalTCPConnection.h"
    23 #include "CLocalTCPConnection.h"
    24 #include "CSocketRouter.h"
    24 #include "Csocketrouter.h"
    25 #include "MIPProxyEngineObserver.h"
    25 #include "MIPProxyEngineObserver.h"
    26 #include "MHostConnection.h"
    26 #include "MHostConnection.h"
    27 #include "MAbstractConnection.h"
    27 #include "MAbstractConnection.h"
    28 
    28 
    29 #define DEBUG_FILENAME "IPProxyEngine.log"
    29 #define DEBUG_FILENAME "IPProxyEngine.log"
   526 void CIPProxyEngine::CloseTCPConnection( TUint aPort )
   526 void CIPProxyEngine::CloseTCPConnection( TUint aPort )
   527     {
   527     {
   528     DEBUG_PRINT( DEBUG_STRING(
   528     DEBUG_PRINT( DEBUG_STRING(
   529         "CIPProxyEngine::CloseTCPConnection(), port=%d"), aPort );
   529         "CIPProxyEngine::CloseTCPConnection(), port=%d"), aPort );
   530 
   530 
       
   531     // Delete local TCP connections
   531     TInt index = FindLocalTCPConn( aPort );
   532     TInt index = FindLocalTCPConn( aPort );
   532     if ( index > -1 )
   533     if ( index > -1 )
   533         {
   534         {
   534         CLocalTCPConnection* conn = iLocalConnArray->At( index );
   535         CLocalTCPConnection* conn = iLocalConnArray->At( index );
   535         iLocalConnArray->Delete( index );
   536         iLocalConnArray->Delete( index );
   536         delete conn;
   537         delete conn;
   537 
   538 
   538         DEBUG_PRINT( DEBUG_STRING(
   539         DEBUG_PRINT( DEBUG_STRING(
   539             "CIPProxyEngine::CloseTCPConnection(), conn deleted.") );
   540             "CIPProxyEngine::CloseTCPConnection(), conn deleted.") );
   540         }
   541         }
       
   542     
       
   543     // stop listening on this port
       
   544     TInt peerListenerArrayCount = iPeerListenerArray->Count();
       
   545     for ( TInt i = 0; i < peerListenerArrayCount; i++ )
       
   546         {
       
   547         CTCPPortListener* listener = iPeerListenerArray->At( i );
       
   548         if(listener->Port() == aPort)
       
   549             {
       
   550             listener->Cancel();
       
   551             iPeerListenerArray->Delete(i);
       
   552             delete listener;
       
   553             break;
       
   554             }
       
   555         }
       
   556     
       
   557     if(iPeerListenerArray->Count() == 0)
       
   558         {
       
   559         iListening = EFalse;
       
   560         }
   541     }
   561     }
   542 
   562 
   543 // -----------------------------------------------------------------------------
   563 // -----------------------------------------------------------------------------
   544 // CIPProxyEngine::CloseAllTCPConnections
   564 // CIPProxyEngine::CloseAllTCPConnections
   545 // -----------------------------------------------------------------------------
   565 // -----------------------------------------------------------------------------
   550         "CIPProxyEngine::CloseAllTCPConnections()" ) );
   570         "CIPProxyEngine::CloseAllTCPConnections()" ) );
   551 
   571 
   552     iSocketRouter->ResetQueue();
   572     iSocketRouter->ResetQueue();
   553     iSocketRouter->RemoveAllPeers();
   573     iSocketRouter->RemoveAllPeers();
   554 
   574 
       
   575     iLocalConnArray->ResetAndDestroy();
       
   576     
   555     StopListening();
   577     StopListening();
   556 
   578 
   557     if ( iPeerListenerArray )
   579     if ( iPeerListenerArray )
   558         {
   580         {
   559         iPeerListenerArray->ResetAndDestroy();
   581         iPeerListenerArray->ResetAndDestroy();