realtimenetprots/sipfw/SIP/ConnectionMgr/src/CTcpTransConnected.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name          : CTcpTransConnected.cpp
       
    15 // Part of       : ConnectionMgr
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include "CTcpTransConnected.h"
       
    23 #include "sipmessage.h"
       
    24 #include "CTransportTcp.h"
       
    25 #include "CSender.h"
       
    26 #include "CListener.h"
       
    27 #include "CommonConsts.h"
       
    28 #include "sipstrings.h"
       
    29 #include "sipstrconsts.h"
       
    30 #include "CSocketContainer.h"
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CTcpTransportConnected::NewL
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CTcpTransportConnected* CTcpTransportConnected::NewL( 
       
    37     const TSIPTransportParams& aParams)
       
    38 	{
       
    39 	CTcpTransportConnected* self = NewLC(aParams);
       
    40 	CleanupStack::Pop(self);
       
    41 	return self;	
       
    42 	}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CTcpTransportConnected::NewLC
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CTcpTransportConnected* CTcpTransportConnected::NewLC(
       
    49     const TSIPTransportParams& aParams)
       
    50 	{
       
    51 	CTcpTransportConnected* self = new (ELeave) CTcpTransportConnected(aParams);
       
    52 	CleanupStack::PushL(self);
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CTcpTransportConnected::SendToNetL
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 void CTcpTransportConnected::SendToNetL(const TSIPTransportParams& aParams,
       
    61                             CSIPMessage& aMessage,
       
    62 							const TInetAddr& aAddr,
       
    63 							TRequestStatus &aStatus,
       
    64 							TUint aOrigTransport,
       
    65 							CTransportTcp* aContext)
       
    66 	{
       
    67 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
    68 	
       
    69 	aContext->GetSender()->SendL(aParams,
       
    70 	                             aMessage,
       
    71                                  aAddr, 
       
    72                                  aOrigTransport, 
       
    73                                  aStatus, 
       
    74                                  EFalse,
       
    75                                  EFalse);
       
    76 	aContext->StartTimerL();
       
    77 	}
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CTcpTransportConnected::CancelSend
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 TBool CTcpTransportConnected::CancelSend(TRequestStatus& aStatus,
       
    84 										 CTransportTcp* aContext)
       
    85 	{
       
    86 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
    87 	
       
    88 	return aContext->GetSender()->FindAndCancel(aStatus);
       
    89 	}
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CTcpTransportConnected::Wait
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CTcpTransportConnected::Wait(CTransportTcp* /*aContext*/)
       
    96 	{
       
    97 	}
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CTcpTransportConnected::HandleMessage
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TBool CTcpTransportConnected::HandleMessage(RStringF aProtocol,
       
   104 											const TInetAddr& aRemoteAddr,
       
   105 											CTransportTcp* aContext)
       
   106 	{
       
   107 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
   108 	
       
   109 	TInetAddr connect;
       
   110 	aContext->SocketContainer().RemoteName(connect);
       
   111 	if (aProtocol == SIPStrings::StringF(SipStrConsts::ETCP) &&
       
   112 		connect.Match(aRemoteAddr) &&
       
   113 		(connect.Port() == aRemoteAddr.Port()))
       
   114 		{
       
   115 		return ETrue;
       
   116 		}
       
   117 	return EFalse;
       
   118 	}
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CTcpTransportConnected::CancelAllRequests
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CTcpTransportConnected::CancelAllRequests(CSIPConnection::TState aReason,
       
   125 											   CTransportTcp* aContext)
       
   126 	{
       
   127 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
   128 	
       
   129 	aContext->GetSender()->CancelAllRequests(aReason);
       
   130 	}
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CTcpTransportConnected::DisconnectedL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CTcpTransportConnected::DisconnectedL(CTransportTcp* aContext)
       
   137 	{
       
   138 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
   139 	
       
   140 	aContext->Remove();
       
   141 	}
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CTcpTransportConnected::SetNeighborState
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CTcpTransportConnected::SetNeighborState(CTcpTransportState* /*aState*/)
       
   148 	{	
       
   149 	}
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CTcpTransportConnected::TimerExpiredL
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CTcpTransportConnected::TimerExpiredL(CTransportTcp* aContext)
       
   156 	{
       
   157 	__ASSERT_DEBUG(aContext, User::Panic(_L("Nullpointer"), KErrGeneral));
       
   158 	
       
   159 	DisconnectedL(aContext);
       
   160 	}
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CTcpTransportConnected::~CTcpTransportConnected
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 CTcpTransportConnected::~CTcpTransportConnected()
       
   167 	{
       
   168 	}
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CTcpTransportConnected::CTcpTransportConnected
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 CTcpTransportConnected::CTcpTransportConnected(
       
   175     const TSIPTransportParams& aParams) : 
       
   176     CTcpTransportState(aParams)
       
   177 	{
       
   178 	}