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) |
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 |
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() |
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 |