wapstack/wapmessageapi/sws/ActiveSocket.cpp
changeset 45 28dbf5a297f4
parent 44 8b72faa1200f
equal deleted inserted replaced
44:8b72faa1200f 45:28dbf5a297f4
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
       
    15 #include "OstTraceDefinitions.h"
       
    16 #ifdef OST_TRACE_COMPILER_IN_USE
       
    17 #include "ActiveSocketTraces.h"
       
    18 #endif
    15 
    19 
    16 #include "ActiveSocket.h"
    20 #include "ActiveSocket.h"
    17 #include <es_wsms.h>
    21 #include <es_wsms.h>
    18 #include "CLWSPPduHandler.h"
    22 #include "CLWSPPduHandler.h"
    19 #include "wapmsgerr.h"
    23 #include "wapmsgerr.h"
    20 #include <wap_sock.h>
    24 #include <wap_sock.h>
    21 #include "WapMessageApiAgent.h"
    25 #include "WapMessageApiAgent.h"
    22 #include "WapSwsLog.h"
       
    23 #include "WapMsgUtils.h"
    26 #include "WapMsgUtils.h"
    24 
    27 
    25 using namespace Wap;
    28 using namespace Wap;
    26 
    29 
    27 void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, Wap::TPort aLocalPort, RConnection* aConnection)
    30 void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, Wap::TPort aLocalPort, RConnection* aConnection)
    79 			CleanupStack::Pop(me);
    82 			CleanupStack::Pop(me);
    80 			break;
    83 			break;
    81 			}
    84 			}
    82 		default:
    85 		default:
    83 		    {
    86 		    {
    84 			LOG(SwsLog::Printf(_L("CActiveSocket::NewL Unknown Bearer Type"));)
    87             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1, "CActiveSocket::NewL Unknown Bearer Type");
    85 			User::Leave(Wap::EBearerError);
    88 			User::Leave(Wap::EBearerError);
    86 		    }
    89 		    }
    87 		}
    90 		}
    88 	}
    91 	}
    89 
    92 
   142             CleanupStack::Pop(me);
   145             CleanupStack::Pop(me);
   143 			break;
   146 			break;
   144 			}
   147 			}
   145 		default:
   148 		default:
   146 		    {
   149 		    {
   147 			LOG(SwsLog::Printf(_L("CActiveSocket::NewL Unknown Bearer Type"));)
   150 		    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1_1, "CActiveSocket::NewL Unknown Bearer Type");
   148 			User::Leave(Wap::EBearerError);
   151 			User::Leave(Wap::EBearerError);
   149 		    }
   152 		    }
   150 		}
   153 		}
   151 	}
   154 	}
   152 
   155 
   268 		TPtr8 des=aAddr->Des();
   271 		TPtr8 des=aAddr->Des();
   269 		TRAP(err, CSWSWapMsgUtils::AnalyseAddrL(iRemoteAddr, iBearerType, des, port))
   272 		TRAP(err, CSWSWapMsgUtils::AnalyseAddrL(iRemoteAddr, iBearerType, des, port))
   270 		}
   273 		}
   271 	else
   274 	else
   272 		{
   275 		{
   273 		LOG(SwsLog::Printf(_L("CActiveSocketUDP::GetServerAddress: Alloc Memory Err=%d"), err);)
   276         OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_GETREMOTEADDRESS_1, "CActiveSocket::GetRemoteAddress: Alloc Memory Err=%d", err);
   274 		}
   277 		}
   275 	return err;
   278 	return err;
   276 	}
   279 	}
   277 
   280 
   278 TInt CActiveSocket::GetLocalPort(Wap::TPort& aLocalPort)
   281 TInt CActiveSocket::GetLocalPort(Wap::TPort& aLocalPort)
   480 	{
   483 	{
   481 	switch (iSocketState)
   484 	switch (iSocketState)
   482 		{
   485 		{
   483 	case ESocketWaitingForLength:
   486 	case ESocketWaitingForLength:
   484 			{
   487 			{
   485 			LOG(SwsLog::Printf(_L("CActiveSocketSMS::RunL() ESocketWaitingForLength"));)
   488 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_1, "CActiveSocketSMS::RunL() ESocketWaitingForLength");
   486 			iMessageRecord->SetDataState(EPendingLength);
   489 			iMessageRecord->SetDataState(EPendingLength);
   487 			iSocketState=ESocketIdle;
   490 			iSocketState=ESocketIdle;
   488 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   491 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   489 			TWapNotificationInfoBuf infoBuf(info);
   492 			TWapNotificationInfoBuf infoBuf(info);
   490 			iNotify->Notification(EPduLengthReceived, infoBuf);
   493 			iNotify->Notification(EPduLengthReceived, infoBuf);
   491 			break;
   494 			break;
   492 			}
   495 			}
   493 	case ESocketWaitingForData:
   496 	case ESocketWaitingForData:
   494 			{
   497 			{
   495 			LOG(SwsLog::Printf(_L("CActiveSocketSMS::RunL() ESocketWaitingForData"));)
   498 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_2, "CActiveSocketSMS::RunL() ESocketWaitingForData");
   496 			iMessageRecord->SetDataState(EPendingData);
   499 			iMessageRecord->SetDataState(EPendingData);
   497 			iSocketState=ESocketIdle;
   500 			iSocketState=ESocketIdle;
   498 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   501 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   499 			TWapNotificationInfoBuf infoBuf(info);
   502 			TWapNotificationInfoBuf infoBuf(info);
   500 			iNotify->Notification(EPduReceived, infoBuf);
   503 			iNotify->Notification(EPduReceived, infoBuf);
   501 			iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0);
   504 			iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0);
   502 			break;
   505 			break;
   503 			}
   506 			}
   504 	default:
   507 	default:
   505 		LOG(SwsLog::Printf(_L("CActiveSocketSMS::RunL() Unknown State")););
   508 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_3, "CActiveSocketSMS::RunL() Unknown State");
   506 		}
   509 		}
   507 	}
   510 	}
   508 void CActiveSocketSMS::DoCancel() 
   511 void CActiveSocketSMS::DoCancel() 
   509 /**
   512 /**
   510 Overload the CActive virtual methods
   513 Overload the CActive virtual methods
   524 			{
   527 			{
   525 			iSocket.CancelRecv();
   528 			iSocket.CancelRecv();
   526 			break;
   529 			break;
   527 			}
   530 			}
   528 	default:
   531 	default:
   529 		LOG(SwsLog::Printf(_L("CActiveSocketSMS::DoCancel() Unknown State")););	
   532 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_DOCANCEL_1, "CActiveSocketSMS::DoCancel() Unknown State");	
   530 		}
   533 		}
   531 	}
   534 	}
   532 
   535 
   533 //
   536 //
   534 // UDP active socket
   537 // UDP active socket
   660 	{
   663 	{
   661 	switch (iSocketState)
   664 	switch (iSocketState)
   662 		{
   665 		{
   663 	case ESocketWaitingForLength:
   666 	case ESocketWaitingForLength:
   664 			{
   667 			{
   665 			LOG(SwsLog::Printf(_L("CActiveSocketUDP::RunL() ESocketWaitingForLength"));)
   668 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_1, "CActiveSocketUDP::RunL() ESocketWaitingForLength");        
   666 			iMessageRecord->SetPduSize(iBuf.Length()+ iRxlength());
   669 			iMessageRecord->SetPduSize(iBuf.Length()+ iRxlength());
   667 			if(iRxlength() > 0)
   670 			if(iRxlength() > 0)
   668 				{
   671 				{
   669 				iMessageRecord->SetDataState(EContinuous);
   672 				iMessageRecord->SetDataState(EContinuous);
   670 				}
   673 				}
   678 			iNotify->Notification(EPduLengthReceived, infoBuf);
   681 			iNotify->Notification(EPduLengthReceived, infoBuf);
   679 			break;
   682 			break;
   680 			}
   683 			}
   681 	case ESocketWaitingForData:
   684 	case ESocketWaitingForData:
   682 			{
   685 			{
   683 			LOG(SwsLog::Printf(_L("CActiveSocketUDP::RunL() ESocketWaitingForData"));)
   686 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_2, "CActiveSocketUDP::RunL() ESocketWaitingForData");
   684 			iMessageRecord->SetDataState(EPendingData);
   687 			iMessageRecord->SetDataState(EPendingData);
   685 			iSocketState=ESocketIdle;
   688 			iSocketState=ESocketIdle;
   686 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   689 			TWapNotificationInfo info(iBearerType, iStatus.Int());
   687 			TWapNotificationInfoBuf infoBuf(info);
   690 			TWapNotificationInfoBuf infoBuf(info);
   688 			iNotify->Notification(EPduReceived, infoBuf);
   691 			iNotify->Notification(EPduReceived, infoBuf);
   689 			break;
   692 			break;
   690 			}
   693 			}
   691 	default:
   694 	default:
   692 		LOG(SwsLog::Printf(_L("CActiveSocketUDP::RunL() Unknown State"));)
   695 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_3, "CActiveSocketUDP::RunL() Unknown State");
   693 		break;
   696 		break;
   694 		}
   697 		}
   695 	}
   698 	}
   696 
   699 
   697 void CActiveSocketUDP::DoCancel()
   700 void CActiveSocketUDP::DoCancel()
   712 	case ESocketWaitingForData:
   715 	case ESocketWaitingForData:
   713 			{
   716 			{
   714 			break;
   717 			break;
   715 			}
   718 			}
   716 	default:
   719 	default:
   717 		LOG(SwsLog::Printf(_L("CActiveSocketUDP::DoCancel() Unknown State")););	
   720 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_DOCANCEL_1, "CActiveSocketUDP::DoCancel() Unknown State");	
   718 		}
   721 		}
   719 	}
   722 	}
   720 
   723 
   721 //
   724 //
   722 //CWapMessageRecord
   725 //CWapMessageRecord
   929 */
   932 */
   930 	{
   933 	{
   931 	if (!iWspHeader && !iWspBody)
   934 	if (!iWspHeader && !iWspBody)
   932 		{
   935 		{
   933 		// if no data, should not be here at all
   936 		// if no data, should not be here at all
   934 		LOG(SwsLog::Printf(_L("CWspMessageRecord::GetWspData() No Data Available"));)
   937         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWSPMESSAGERECORD_GETWSPDATA_1, "CWspMessageRecord::GetWspData() No Data Available");
   935 		CleanUpData();
   938 		CleanUpData();
   936 		return KErrBadDescriptor;
   939 		return KErrBadDescriptor;
   937 		}
   940 		}
   938 	TInt ret=KErrNone;
   941 	TInt ret=KErrNone;
   939 	//Copy the transaction ID
   942 	//Copy the transaction ID
  1063 */
  1066 */
  1064 	{
  1067 	{
  1065 	if (!iPdu)
  1068 	if (!iPdu)
  1066 		{
  1069 		{
  1067 		//Should not be here at all
  1070 		//Should not be here at all
  1068 		LOG(SwsLog::Printf(_L("CWdpMessageRecord::GetPduData No Data Available"));)
  1071         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWDPMESSAGERECORD_GETPDUDATA_1, "CWdpMessageRecord::GetPduData No Data Available");
  1069 		CleanUpData();
  1072 		CleanUpData();
  1070 		return KErrBadDescriptor;
  1073 		return KErrBadDescriptor;
  1071 		}
  1074 		}
  1072 	TInt ret=KErrNone;
  1075 	TInt ret=KErrNone;
  1073 	TInt bufLength=aBuffer.MaxLength();
  1076 	TInt bufLength=aBuffer.MaxLength();