smsprotocols/smsstack/wapprot/Src/ws_prvdr.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 //
    16 //
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
       
    21 
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "ws_prvdrTraces.h"
       
    26 #endif
    21 
    27 
    22 #include <e32std.h>
    28 #include <e32std.h>
    23 #include <wap_sock.h>
    29 #include <wap_sock.h>
    24 #include "ws_main.h"
    30 #include "ws_main.h"
    25 #include "es_wsms.h"
    31 #include "es_wsms.h"
    26 #include "WAPDGRM.H"
    32 #include "WAPDGRM.H"
    27 #include "ws_obsvr.h"
    33 #include "ws_obsvr.h"
    28 #include "smsprot.h"
    34 #include "smsprot.h"
    29 #include <es_mbuf.h>
    35 #include <es_mbuf.h>
       
    36 #include "smsstacklog.h"
    30 
    37 
    31 //
    38 //
    32 // implementation of CWapSmsProvider
    39 // implementation of CWapSmsProvider
    33 //
    40 //
    34 
    41 
    35 	// CWapSmsProvider policies
    42     // CWapSmsProvider policies
    36 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderSetLocalNamePolicy, ECapabilityNetworkServices );
    43     static _LIT_SECURITY_POLICY_C1(wapSmsProviderSetLocalNamePolicy, ECapabilityNetworkServices );
    37 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderSetOptionPolicy, ECapability_None);
    44     static _LIT_SECURITY_POLICY_C1(wapSmsProviderSetOptionPolicy, ECapability_None);
    38 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetLengthIoctlPolicy,ECapability_None);
    45     static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetLengthIoctlPolicy,ECapability_None);
    39 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetMessageParamLengthIoctlPolicy,ECapability_None);
    46     static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetMessageParamLengthIoctlPolicy,ECapability_None);
    40 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetMessageParametersIoctlPolicy,ECapabilityReadDeviceData);
    47     static _LIT_SECURITY_POLICY_C1(wapSmsProviderGetMessageParametersIoctlPolicy,ECapabilityReadDeviceData);
    41 	static _LIT_SECURITY_POLICY_C1(wapSmsProviderWritePolicy,ECapabilityNetworkServices);
    48     static _LIT_SECURITY_POLICY_C1(wapSmsProviderWritePolicy,ECapabilityNetworkServices);
    42 
    49 
    43 
    50 
    44 /**
    51 /**
    45  *  Factory
    52  *  Factory
    46  */
    53  */
    47 CWapSmsProvider* CWapSmsProvider::NewL(CWapSmsProtocol* aProtocol)
    54 CWapSmsProvider* CWapSmsProvider::NewL(CWapSmsProtocol* aProtocol)
    48 	{
    55     {
    49 	LOGWAPPROT1("CWapSmsProvider::NewL()");
    56     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_NEWL_1, "CWapSmsProvider::NewL()");
    50 
    57 
    51 	CWapSmsProvider* provider=new(ELeave) CWapSmsProvider(aProtocol);
    58     CWapSmsProvider* provider=new(ELeave) CWapSmsProvider(aProtocol);
    52 	CleanupStack::PushL(provider);
    59     CleanupStack::PushL(provider);
    53 	provider->iWapSmsProviderWrite = CWapSmsProviderWrite::NewL(*provider);
    60     provider->iWapSmsProviderWrite = CWapSmsProviderWrite::NewL(*provider);
    54 	CleanupStack::Pop();
    61     CleanupStack::Pop();
    55 	return provider;
    62     return provider;
    56 	} // CWapSmsProvider::NewL
    63     } // CWapSmsProvider::NewL
    57 
    64 
    58 
    65 
    59 /**
    66 /**
    60  *  Constructor
    67  *  Constructor
    61  */
    68  */
    62 CWapSmsProvider::CWapSmsProvider(CWapSmsProtocol* aProtocol)
    69 CWapSmsProvider::CWapSmsProvider(CWapSmsProtocol* aProtocol)
    63     :iMessageType(ESmartMessage)
    70     :iMessageType(ESmartMessage)
    64     ,iProtocol(aProtocol)
    71     ,iProtocol(aProtocol)
    65     ,iSendPending(EFalse)
    72     ,iSendPending(EFalse)
    66 	,iIoctlOutstanding(EFalse)
    73     ,iIoctlOutstanding(EFalse)
    67 	,iIsNewStyleClient(EFalse)
    74     ,iIsNewStyleClient(EFalse)
    68 	,iStatusReportScheme(EWapSmsDefault)
    75     ,iStatusReportScheme(EWapSmsDefault)
    69     {
    76     {
    70     iRecvdMsgQueue.SetOffset(CWapDatagram::LinkOffset());
    77     iRecvdMsgQueue.SetOffset(CWapDatagram::LinkOffset());
    71     } // CWapSmsProvider::CWapSmsProvider
    78     } // CWapSmsProvider::CWapSmsProvider
    72 
    79 
    73 
    80 
    91 
    98 
    92 /**
    99 /**
    93  *  Return WAPSMS options
   100  *  Return WAPSMS options
    94  */
   101  */
    95 TInt CWapSmsProvider::GetOption(TUint aLevel,TUint aName, TDes8& aOption)const
   102 TInt CWapSmsProvider::GetOption(TUint aLevel,TUint aName, TDes8& aOption)const
    96 	{
   103     {
    97 	LOGWAPPROT1("CWapSmsProvider::GetOption");
   104     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_GETOPTION_1, "CWapSmsProvider::GetOption");
    98 
   105 
    99 	TInt ret=KErrNone;
   106     TInt ret=KErrNone;
   100 	if (TInt(aLevel)==KWapSmsOptionLevel && TInt(aName)==KWapSmsOptionNameDCS)
   107     if (TInt(aLevel)==KWapSmsOptionLevel && TInt(aName)==KWapSmsOptionNameDCS)
   101 		aOption = TPtrC8((TText8*)&iDataCodingScheme,sizeof(TWapSmsDataCodingScheme));
   108         aOption = TPtrC8((TText8*)&iDataCodingScheme,sizeof(TWapSmsDataCodingScheme));
   102 	else
   109     else
   103 		ret=iProtocol->GetOption(aLevel,aName,aOption,NULL);
   110         ret=iProtocol->GetOption(aLevel,aName,aOption,NULL);
   104 	return ret;
   111     return ret;
   105 	} // CWapSmsProvider::GetOption
   112     } // CWapSmsProvider::GetOption
   106 
   113 
   107 
   114 
   108 /**
   115 /**
   109  *  Set WAPSMS options
   116  *  Set WAPSMS options
   110  *  
   117  *  
   111  *  @capability None
   118  *  @capability None
   112  *  
   119  *  
   113  */
   120  */
   114 TInt CWapSmsProvider::SetOption(TUint aLevel, TUint aName, const TDesC8& aOption)
   121 TInt CWapSmsProvider::SetOption(TUint aLevel, TUint aName, const TDesC8& aOption)
   115 	{
   122     {
   116 	LOGWAPPROT1("CWapSmsProvider::SetOption");
   123     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SETOPTION_1, "CWapSmsProvider::SetOption");
   117 	if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderSetOptionPolicy,"CWapSmsProvider SetOption policy check") != KErrNone))
   124     if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderSetOptionPolicy,"CWapSmsProvider SetOption policy check") != KErrNone))
   118 		{
   125         {
   119 		return KErrPermissionDenied;
   126         return KErrPermissionDenied;
   120 		}
   127         }
   121 
   128 
   122 	TInt ret=KErrNone;
   129     TInt ret=KErrNone;
   123 	if (TInt(aLevel)==KWapSmsOptionLevel)
   130     if (TInt(aLevel)==KWapSmsOptionLevel)
   124 	{
   131     {
   125 		switch(TInt(aName))
   132         switch(TInt(aName))
   126 		{
   133         {
   127 		case KWapSmsOptionNameDCS:
   134         case KWapSmsOptionNameDCS:
   128 			{
   135             {
   129 			iDataCodingScheme = static_cast<TWapSmsDataCodingScheme>(*aOption.Ptr());
   136             iDataCodingScheme = static_cast<TWapSmsDataCodingScheme>(*aOption.Ptr());
   130 			break;
   137             break;
   131 			}
   138             }
   132 		case KWapSmsOptionWapDatagram:
   139         case KWapSmsOptionWapDatagram:
   133 			{
   140             {
   134 			iMessageType=EWapDatagram;
   141             iMessageType=EWapDatagram;
   135 			break;
   142             break;
   136 			}
   143             }
   137 		case KWapSmsStatusReportScheme:
   144         case KWapSmsStatusReportScheme:
   138 			{
   145             {
   139 			iStatusReportScheme = static_cast<TWapSmsStatusReportScheme>(*aOption.Ptr());
   146             iStatusReportScheme = static_cast<TWapSmsStatusReportScheme>(*aOption.Ptr());
   140 			break;				
   147             break;              
   141 			}
   148             }
   142 		case KWapSmsOptionNewStyleClient:
   149         case KWapSmsOptionNewStyleClient:
   143 			{
   150             {
   144 			iIsNewStyleClient = ETrue;
   151             iIsNewStyleClient = ETrue;
   145 			break;
   152             break;
   146 			}
   153             }
   147 		case KWapSmsOptionOKToDeleteMessage:
   154         case KWapSmsOptionOKToDeleteMessage:
   148 			{
   155             {
   149 			//Get the first message from the queue
   156             //Get the first message from the queue
   150 			CWapDatagram* msg = iRecvdMsgQueue.First();
   157             CWapDatagram* msg = iRecvdMsgQueue.First();
   151 			//Find and delete from SAR
   158             //Find and delete from SAR
   152 			TBool found=iProtocol->FindAndDeleteMsg(*msg);
   159             TBool found=iProtocol->FindAndDeleteMsg(*msg);
   153 			if(!found)
   160             if(!found)
   154 				{
   161                 {
   155 				LOGWAPPROT1("CWapSmsProvider::SetOption: Error. Couldn't find the message in the SAR for deletion");
   162                 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SETOPTION_2, "CWapSmsProvider::SetOption: Error. Couldn't find the message in the SAR for deletion");
   156 				break;
   163                 break;
   157 				}
   164                 }
   158 			//Remove from the queue
   165             //Remove from the queue
   159 			iRecvdMsgQueue.Remove(*msg);
   166             iRecvdMsgQueue.Remove(*msg);
   160 			delete msg;
   167             delete msg;
   161 			break;
   168             break;
   162 			}
   169             }
   163 		default:
   170         default:
   164 			ret=KErrNotSupported;
   171             ret=KErrNotSupported;
   165 		}
   172         }
   166 
   173 
   167 	}
   174     }
   168 	else
   175     else
   169 	{
   176     {
   170 		ret=iProtocol->SetOption(aLevel,aName,aOption,NULL);
   177         ret=iProtocol->SetOption(aLevel,aName,aOption,NULL);
   171 	}
   178     }
   172 	return ret;
   179     return ret;
   173 	} // CWapSmsProvider::SetOption
   180     } // CWapSmsProvider::SetOption
   174 
   181 
   175 
   182 
   176 /**
   183 /**
   177  *  Shutdown the SAP
   184  *  Shutdown the SAP
   178  */
   185  */
   179 void CWapSmsProvider::Shutdown(TCloseType aType)
   186 void CWapSmsProvider::Shutdown(TCloseType aType)
   180 	{
   187     {
   181 	LOGWAPPROT1("CWapSmsProvider::Shutdown");
   188     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SHUTDOWN_1, "CWapSmsProvider::Shutdown");
   182 	if (aType!=CServProviderBase::EImmediate)
   189     if (aType!=CServProviderBase::EImmediate)
   183 		iSocket->CanClose();
   190         iSocket->CanClose();
   184 	} // CWapSmsProvider::Shutdown
   191     } // CWapSmsProvider::Shutdown
   185 
   192 
   186 
   193 
   187 /**
   194 /**
   188  *  Setup datagram with socket specific options and forward to protocol
   195  *  Setup datagram with socket specific options and forward to protocol
   189  *  Return zero to block the send - will be completed by CWapSapMessageSender
   196  *  Return zero to block the send - will be completed by CWapSapMessageSender
   190  *  
   197  *  
   191  *  @capability NetworkServices
   198  *  @capability NetworkServices
   192  */
   199  */
   193 TInt CWapSmsProvider::Write(RMBufChain& aBufChain, TUint /*options*/, TSockAddr* aAddr)
   200 TInt CWapSmsProvider::Write(RMBufChain& aBufChain, TUint /*options*/, TSockAddr* aAddr)
   194 	{
   201     {
   195 	LOGWAPPROT1("CWapSmsProvider::Write()");
   202     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_WRITE_1, "CWapSmsProvider::Write()");
   196 
   203 
   197 		if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderWritePolicy,"CWapSmsProvider Write policy check") != KErrNone))
   204         if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderWritePolicy,"CWapSmsProvider Write policy check") != KErrNone))
   198 		{
   205         {
   199 		return KErrPermissionDenied;
   206         return KErrPermissionDenied;
   200 		}
   207         }
   201 	// @note: LOGIFH2A2 macro for logging esock write
   208     // @note: LOGIFH2A2 macro for logging esock write
   202 #ifdef SMSLOGGERIF
   209 #ifdef SMSLOGGERIF
   203 	TInt length = aBufChain.Length();
   210     TInt length = aBufChain.Length();
   204 	LOGWAPPROT2("CWapSmsProvider::Write [%d bytes]", length);
   211     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_WRITE_2, "CWapSmsProvider::Write [%d bytes]", length);
   205 	TBuf8<0x100> dumpBuf;
   212     TBuf8<0x100> dumpBuf;
   206 	if(length > 0x100)
   213     if(length > 0x100)
   207 		{
   214         {
   208 
   215 
   209 		TInt parts=0;
   216         TInt parts=0;
   210 		TInt offset = 0;
   217         TInt offset = 0;
   211  		while (offset < length)
   218         while (offset < length)
   212  			{
   219             {
   213 			aBufChain.CopyOut(dumpBuf, offset);
   220             aBufChain.CopyOut(dumpBuf, offset);
   214 			offset += length;
   221             offset += length;
   215  			LOGIF2(_L8("ESock WAP concantonated part: %d"),parts++);
   222             LOGIF2(_L8("ESock WAP concantonated part: %d"),parts++);
   216  			LOGIF2(_L8("ESOCK WRITE: %S"),&dumpBuf);
   223             LOGIF2(_L8("ESOCK WRITE: %S"),&dumpBuf);
   217  			LOGIFH2A2(_L8("ESOCK WRITE: "),dumpBuf);
   224             LOGIFH2A2(_L8("ESOCK WRITE: "),dumpBuf);
   218  			}
   225             }
   219 
   226 
   220  	}
   227     }
   221  	else
   228     else
   222  	{
   229     {
   223 		aBufChain.CopyOut(dumpBuf, 0);
   230         aBufChain.CopyOut(dumpBuf, 0);
   224  		LOGIF2(_L8("ESOCK WRITE: %S"),&dumpBuf);
   231         LOGIF2(_L8("ESOCK WRITE: %S"),&dumpBuf);
   225  		LOGIFH2A2(_L8("ESOCK WRITE: "),dumpBuf);
   232         LOGIFH2A2(_L8("ESOCK WRITE: "),dumpBuf);
   226 	}
   233     }
   227 #endif
   234 #endif
   228 
   235 
   229 	// Note that if this fails somehow it still frees the buf chain and sets itself active - it's
   236     // Note that if this fails somehow it still frees the buf chain and sets itself active - it's
   230 	// not clear to me whether this is good behaviour but it's the pre-mbuf behaviour too
   237     // not clear to me whether this is good behaviour but it's the pre-mbuf behaviour too
   231 	iWapSmsProviderWrite->Start(aBufChain, *aAddr);
   238     iWapSmsProviderWrite->Start(aBufChain, *aAddr);
   232 	return KErrNone;
   239     return KErrNone;
   233 	} // CWapSmsProvider::Write
   240     } // CWapSmsProvider::Write
   234 
   241 
   235 
   242 
   236 /**
   243 /**
   237  *  Read a datagram off the queue
   244  *  Read a datagram off the queue
   238  */
   245  */
   239 TInt CWapSmsProvider::GetData(RMBufChain& aBufChain, TUint aLength, TUint /*options*/,TSockAddr* aAddr)
   246 TInt CWapSmsProvider::GetData(RMBufChain& aBufChain, TUint aLength, TUint /*options*/,TSockAddr* aAddr)
   240 	{
   247     {
   241 	LOGWAPPROT1("CWapSmsProvider::GetData()");
   248     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_GETDATA_1, "CWapSmsProvider::GetData()");
   242 
   249 
   243 	CWapDatagram* msg = iRecvdMsgQueue.First();
   250     CWapDatagram* msg = iRecvdMsgQueue.First();
   244 	if(!iIsNewStyleClient)
   251     if(!iIsNewStyleClient)
   245 		{
   252         {
   246 		iRecvdMsgQueue.Remove(*msg);
   253         iRecvdMsgQueue.Remove(*msg);
   247 		}
   254         }
   248 	TInt err = msg->WapDatagram(aBufChain, aLength);
   255     TInt err = msg->WapDatagram(aBufChain, aLength);
   249 
   256 
   250 	//@note: LOGIFH2A2 macro for logging esock getdata
   257     //@note: LOGIFH2A2 macro for logging esock getdata
   251 	LOGWAPPROT1("CWapSmsProvider::GetData");
   258     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_GETDATA_2, "CWapSmsProvider::GetData");
   252 	// Logging migrated to WapDatagram() for ease of descriptor ref
   259     // Logging migrated to WapDatagram() for ease of descriptor ref
   253 
   260 
   254 	if (err > 0 && aAddr)
   261     if (err > 0 && aAddr)
   255 		{
   262         {
   256 		TWapAddr* wapAddr = reinterpret_cast<TWapAddr*>(aAddr);
   263         TWapAddr* wapAddr = reinterpret_cast<TWapAddr*>(aAddr);
   257 		TInt toPort,fromPort;
   264         TInt toPort,fromPort;
   258 		msg->Ports(fromPort,toPort);
   265         msg->Ports(fromPort,toPort);
   259 		wapAddr->SetWapPort(static_cast<TWapPortNumber>(fromPort));
   266         wapAddr->SetWapPort(static_cast<TWapPortNumber>(fromPort));
   260 		TBuf8<KMaxSockAddrSize> addrBuf;
   267         TBuf8<KMaxSockAddrSize> addrBuf;
   261 		addrBuf.Copy(msg->FromAddress());
   268         addrBuf.Copy(msg->FromAddress());
   262 		wapAddr->SetWapAddress(addrBuf);
   269         wapAddr->SetWapAddress(addrBuf);
   263 		}
   270         }
   264 	if(!iIsNewStyleClient)
   271     if(!iIsNewStyleClient)
   265 		{
   272         {
   266 		delete msg;
   273         delete msg;
   267 		}
   274         }
   268 	return err > 0? 1: err;		// datagrams are atoms not byte counts
   275     return err > 0? 1: err;     // datagrams are atoms not byte counts
   269 	} // CWapSmsProvider::GetData
   276     } // CWapSmsProvider::GetData
   270 
   277 
   271 
   278 
   272 /**
   279 /**
   273  *  New data has arrived notify ESOCK.
   280  *  New data has arrived notify ESOCK.
   274  */
   281  */
   275 void CWapSmsProvider::NewData(CWapDatagram* aMsg)
   282 void CWapSmsProvider::NewData(CWapDatagram* aMsg)
   276 	{
   283     {
   277 	TBool notifyEsock = EFalse;
   284     TBool notifyEsock = EFalse;
   278 	LOGWAPPROT1("CWapSmsProvider::NewData");
   285     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_NEWDATA_1, "CWapSmsProvider::NewData");
   279 
   286 
   280 	if(iIoctlOutstanding && iName==KSOGetLength && iIsNewStyleClient)
   287     if(iIoctlOutstanding && iName==KSOGetLength && iIsNewStyleClient)
   281 		{
   288         {
   282 		TPckgBuf<TInt> buf= aMsg->WapDatagramLength();
   289         TPckgBuf<TInt> buf= aMsg->WapDatagramLength();
   283 		iSocket->IoctlComplete(&buf);
   290         iSocket->IoctlComplete(&buf);
   284 		iIoctlOutstanding= EFalse;
   291         iIoctlOutstanding= EFalse;
   285 		iName= NULL;
   292         iName= NULL;
   286 		notifyEsock = ETrue;
   293         notifyEsock = ETrue;
   287 		}
   294         }
   288 	else if(iIoctlOutstanding && iName==KSOGetMessageParametersLength && iIsNewStyleClient)
   295     else if(iIoctlOutstanding && iName==KSOGetMessageParametersLength && iIsNewStyleClient)
   289 		{
   296         {
   290 		CBufFlat* buffer = aMsg->SmsExternalisedStream();
   297         CBufFlat* buffer = aMsg->SmsExternalisedStream();
   291 		TPckgBuf<TInt> buf = buffer->Size();
   298         TPckgBuf<TInt> buf = buffer->Size();
   292 		iSocket->IoctlComplete(&buf);
   299         iSocket->IoctlComplete(&buf);
   293 		iIoctlOutstanding= EFalse;
   300         iIoctlOutstanding= EFalse;
   294 		iName= NULL;
   301         iName= NULL;
   295 		notifyEsock = ETrue;
   302         notifyEsock = ETrue;
   296 		}
   303         }
   297 	else if(iIoctlOutstanding && iName==KSOGetMessageParameters && iIsNewStyleClient)
   304     else if(iIoctlOutstanding && iName==KSOGetMessageParameters && iIsNewStyleClient)
   298 		{
   305         {
   299 		CBufFlat* buffer = aMsg->SmsExternalisedStream();
   306         CBufFlat* buffer = aMsg->SmsExternalisedStream();
   300 		TPtr8 buf = buffer->Ptr(0);
   307         TPtr8 buf = buffer->Ptr(0);
   301 		iSocket->IoctlComplete(&buf);
   308         iSocket->IoctlComplete(&buf);
   302 		iIoctlOutstanding= EFalse;
   309         iIoctlOutstanding= EFalse;
   303 		iName= NULL;
   310         iName= NULL;
   304 		notifyEsock = ETrue;
   311         notifyEsock = ETrue;
   305 		}
   312         }
   306 	else if(iName!=KSOGetLength && iName!=KSOGetMessageParametersLength && iName!=KSOGetMessageParameters && iIsNewStyleClient)
   313     else if(iName!=KSOGetLength && iName!=KSOGetMessageParametersLength && iName!=KSOGetMessageParameters && iIsNewStyleClient)
   307 		{
   314         {
   308 		notifyEsock= EFalse;
   315         notifyEsock= EFalse;
   309 		}
   316         }
   310 
   317 
   311 	if(!iIsNewStyleClient || notifyEsock)
   318     if(!iIsNewStyleClient || notifyEsock)
   312 		iSocket->NewData(1);
   319         iSocket->NewData(1);
   313 	//else we notify ESock in IOCTL for new client
   320     //else we notify ESock in IOCTL for new client
   314 	} // CWapSmsProvider::NewData
   321     } // CWapSmsProvider::NewData
   315 
   322 
   316 
   323 
   317 /**
   324 /**
   318  *  Error happened, notify ESOCK
   325  *  Error happened, notify ESOCK
   319  */
   326  */
   320 void CWapSmsProvider::Error(TInt aError, TUint aOperationMask)
   327 void CWapSmsProvider::Error(TInt aError, TUint aOperationMask)
   321 	{
   328     {
   322 	LOGWAPPROT3("CWapSmsProvider::Error [aError=%d, mask=%d] ", aError, aOperationMask);
   329     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_ERROR_1, "CWapSmsProvider::Error [aError=%d, mask=%u] ", aError, aOperationMask);
   323 
   330 
   324 	iSocket->Error(aError, aOperationMask);
   331     iSocket->Error(aError, aOperationMask);
   325 	} // CWapSmsProvider::Error
   332     } // CWapSmsProvider::Error
   326 
   333 
   327 
   334 
   328 /**
   335 /**
   329  *  Return the offset to the dblquelink
   336  *  Return the offset to the dblquelink
   330  */
   337  */
   331 TInt CWapSmsProvider::LinkOffset()
   338 TInt CWapSmsProvider::LinkOffset()
   332 	{
   339     {
   333 	LOGWAPPROT1("CWapSmsProvider::LinkOffset");
   340     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_LINKOFFSET_1, "CWapSmsProvider::LinkOffset");
   334 
   341 
   335 	return _FOFF(CWapSmsProvider,iSAPLink);
   342     return _FOFF(CWapSmsProvider,iSAPLink);
   336 	} // CWapSmsProvider::LinkOffset
   343     } // CWapSmsProvider::LinkOffset
   337 
   344 
   338 
   345 
   339 /**
   346 /**
   340  *  Return the address associated with the sap
   347  *  Return the address associated with the sap
   341  */
   348  */
   342 void CWapSmsProvider::LocalName(TSockAddr& aAddr) const
   349 void CWapSmsProvider::LocalName(TSockAddr& aAddr) const
   343 	{
   350     {
   344 	LOGWAPPROT1("CWapSmsProvider::LocalName");
   351     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_LOCALNAME_1, "CWapSmsProvider::LocalName");
   345 
   352 
   346 	Mem::Copy(&aAddr,&iLocalAddress,sizeof(TSockAddr));
   353     Mem::Copy(&aAddr,&iLocalAddress,sizeof(TSockAddr));
   347 	} // CWapSmsProvider::LocalName
   354     } // CWapSmsProvider::LocalName
   348 
   355 
   349 
   356 
   350 /**
   357 /**
   351  *  Set the local address of the sap - called by RSocket::Bind
   358  *  Set the local address of the sap - called by RSocket::Bind
   352  *  
   359  *  
   353  *  @capability NetworkServices
   360  *  @capability NetworkServices
   354  */
   361  */
   355 TInt CWapSmsProvider::SetLocalName(TSockAddr& aAddr)
   362 TInt CWapSmsProvider::SetLocalName(TSockAddr& aAddr)
   356 	{
   363     {
   357 	LOGWAPPROT1("CWapSmsProvider::SetLocalName()");
   364     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SETLOCALNAME_1, "CWapSmsProvider::SetLocalName()");
   358 
   365 
   359 		if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderSetLocalNamePolicy,"CWapSmsProvider SetLocalName policy check") != KErrNone))
   366         if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderSetLocalNamePolicy,"CWapSmsProvider SetLocalName policy check") != KErrNone))
   360 		{
   367         {
   361 		return KErrPermissionDenied;
   368         return KErrPermissionDenied;
   362 		}
   369         }
   363 	TWapAddr* wapAddr = reinterpret_cast<TWapAddr*>(&aAddr);
   370     TWapAddr* wapAddr = reinterpret_cast<TWapAddr*>(&aAddr);
   364 	LOGWAPPROT2("CWapSmsProvider::SetLocalName %d",wapAddr->WapPort());
   371     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SETLOCALNAME_2, "CWapSmsProvider::SetLocalName %d",wapAddr->WapPort());
   365 	// Due ESOCK interface port EWapPortUnspecified value (-1)  can be transferred as a maximum unsigned 16 int
   372     // Due ESOCK interface port EWapPortUnspecified value (-1)  can be transferred as a maximum unsigned 16 int
   366 	if (wapAddr->WapPort()==EWapPortUnspecified || wapAddr->WapPort()==static_cast<TUint16>(EWapPortUnspecified))
   373     if (wapAddr->WapPort()==EWapPortUnspecified || wapAddr->WapPort()==static_cast<TUint16>(EWapPortUnspecified))
   367 		{
   374         {
   368 		if(!iProtocol->AllocateLocalAddress(iLocalAddress))
   375         if(!iProtocol->AllocateLocalAddress(iLocalAddress))
   369 			return KErrInUse;
   376             return KErrInUse;
   370 		else return KErrNone;
   377         else return KErrNone;
   371 		}
   378         }
   372 
   379 
   373 
   380 
   374 	TInt ret=iProtocol->AddrAlreadyUsedByWAP(*wapAddr,this);
   381     TInt ret=iProtocol->AddrAlreadyUsedByWAP(*wapAddr,this);
   375 	if(ret == KErrInUse) return ret;
   382     if(ret == KErrInUse) return ret;
   376 	else if(ret == KErrAlreadyExists) return KErrNone;
   383     else if(ret == KErrAlreadyExists) return KErrNone;
   377 
   384 
   378 	TSmsAddr addr;
   385     TSmsAddr addr;
   379 	if(wapAddr->Port() <=255)
   386     if(wapAddr->Port() <=255)
   380 		addr.SetSmsAddrFamily(ESmsAddrApplication8BitPort);
   387         addr.SetSmsAddrFamily(ESmsAddrApplication8BitPort);
   381 	else
   388     else
   382 		addr.SetSmsAddrFamily(ESmsAddrApplication16BitPort);
   389         addr.SetSmsAddrFamily(ESmsAddrApplication16BitPort);
   383 
   390 
   384 	addr.SetPort(wapAddr->Port());
   391     addr.SetPort(wapAddr->Port());
   385 
   392 
   386 	if((iProtocol->SmsProtocol()->SmsAddrIsAlreadyUsed(NULL,addr)))
   393     if((iProtocol->SmsProtocol()->SmsAddrIsAlreadyUsed(NULL,addr)))
   387 		return KErrInUse;
   394         return KErrInUse;
   388 
   395 
   389 	Mem::Copy(&iLocalAddress,&aAddr,sizeof(TSockAddr));
   396     Mem::Copy(&iLocalAddress,&aAddr,sizeof(TSockAddr));
   390 	TInt err;
   397     TInt err;
   391 	TRAP(err,ret = iProtocol->CheckSarL(*wapAddr,this));
   398     TRAP(err,ret = iProtocol->CheckSarL(*wapAddr,this));
   392 	if(err!=KErrNone)
   399     if(err!=KErrNone)
   393 			return err;
   400             return err;
   394 	if(ret!=KErrNone)
   401     if(ret!=KErrNone)
   395 		{
   402         {
   396 		Error(ret,MSocketNotify::EErrorAllOperations);
   403         Error(ret,MSocketNotify::EErrorAllOperations);
   397 		}
   404         }
   398 	return KErrNone;
   405     return KErrNone;
   399 	} // RSocket::Bind
   406     } // RSocket::Bind
   400 
   407 
   401 
   408 
   402 /**
   409 /**
   403  *  Returns true if aAddr matches the local address of the sap
   410  *  Returns true if aAddr matches the local address of the sap
   404  */
   411  */
   405 TBool CWapSmsProvider::MatchesLocalAddress(const TWapAddr& aAddr)
   412 TBool CWapSmsProvider::MatchesLocalAddress(const TWapAddr& aAddr)
   406 	{
   413     {
   407 	LOGWAPPROT1("CWapSmsProvider::MatchesLocalAddress");
   414     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_MATCHESLOCALADDRESS_1, "CWapSmsProvider::MatchesLocalAddress");
   408 
   415 
   409 	return (iLocalAddress == aAddr);
   416     return (iLocalAddress == aAddr);
   410 	} // CWapSmsProvider::MatchesLocalAddress
   417     } // CWapSmsProvider::MatchesLocalAddress
   411 
   418 
   412 //
   419 //
   413 
   420 
   414 
   421 
   415 /**
   422 /**
   425  *  @param aName the IOCTL name.
   432  *  @param aName the IOCTL name.
   426  *  @param aOption the IOCTL option.
   433  *  @param aOption the IOCTL option.
   427  *  
   434  *  
   428  */
   435  */
   429 void CWapSmsProvider::Ioctl(TUint aLevel,TUint aName,TDes8 * /*aOption*/)
   436 void CWapSmsProvider::Ioctl(TUint aLevel,TUint aName,TDes8 * /*aOption*/)
   430 	{
   437     {
   431 	LOGWAPPROT3("CWapSmsProvider::Ioctl [aLevel=%d, aName=%d]", aLevel, aName);
   438     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_IOCTL_1, "CWapSmsProvider::Ioctl [aLevel=%u, aName=%u]", aLevel, aName);
   432 	LOGWAPPROT2("CWapSmsProtocol::Ioctl [provider=0x%08x]",this);
   439     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_IOCTL_2, "CWapSmsProtocol::Ioctl [provider=0x%08x]",this);
   433 
   440 
   434 	iName=aName;
   441     iName=aName;
   435 	switch (aLevel)
   442     switch (aLevel)
   436 		{
   443         {
   437 		case KSolWapProv:
   444         case KSolWapProv:
   438 			{
   445             {
   439 		    if(iIoctlOutstanding || !iIsNewStyleClient)
   446             if(iIoctlOutstanding || !iIsNewStyleClient)
   440 				{
   447                 {
   441 				Error(KErrInUse,MSocketNotify::EErrorIoctl);
   448                 Error(KErrInUse,MSocketNotify::EErrorIoctl);
   442 				break;
   449                 break;
   443 				}
   450                 }
   444 			switch (iName)
   451             switch (iName)
   445 				{
   452                 {
   446 				case KSOGetLength:
   453                 case KSOGetLength:
   447 				//
   454                 //
   448 				// Get the length
   455                 // Get the length
   449 				//
   456                 //
   450 					{
   457                     {
   451 					if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetLengthIoctlPolicy,"CWapSmsProvider GetLength Ioctl policy check") != KErrNone))
   458                     if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetLengthIoctlPolicy,"CWapSmsProvider GetLength Ioctl policy check") != KErrNone))
   452         				{
   459                         {
   453         				Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   460                         Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   454         				return;
   461                         return;
   455         				}
   462                         }
   456 					iIoctlOutstanding = ETrue;
   463                     iIoctlOutstanding = ETrue;
   457 					//check the queue for any other message for this client and call new data if any exist
   464                     //check the queue for any other message for this client and call new data if any exist
   458 					if(!iRecvdMsgQueue.IsEmpty())
   465                     if(!iRecvdMsgQueue.IsEmpty())
   459 						{
   466                         {
   460 						CWapDatagram* msg = iRecvdMsgQueue.First();
   467                         CWapDatagram* msg = iRecvdMsgQueue.First();
   461 						//check the datagram.
   468                         //check the datagram.
   462 						if(msg->IsComplete())
   469                         if(msg->IsComplete())
   463 							{
   470                             {
   464 							NewData(msg);
   471                             NewData(msg);
   465 							}
   472                             }
   466 						else
   473                         else
   467 							{
   474                             {
   468 							//	else notify the client with error.
   475                             //  else notify the client with error.
   469 							//	Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   476                             //  Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   470 							Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   477                             Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   471 							iIoctlOutstanding = EFalse;
   478                             iIoctlOutstanding = EFalse;
   472 							}
   479                             }
   473 
   480 
   474 						}
   481                         }
   475 					break;
   482                     break;
   476 					}
   483                     }
   477 				
   484                 
   478 				case KSOGetMessageParametersLength:
   485                 case KSOGetMessageParametersLength:
   479 				//
   486                 //
   480 				// Get the Message Parameters Length
   487                 // Get the Message Parameters Length
   481 				//
   488                 //
   482 					{
   489                     {
   483 					if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetMessageParamLengthIoctlPolicy,"CWapSmsProvider KSOGetMessageParametersLength Ioctl policy check") != KErrNone))
   490                     if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetMessageParamLengthIoctlPolicy,"CWapSmsProvider KSOGetMessageParametersLength Ioctl policy check") != KErrNone))
   484         				{
   491                         {
   485         				Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   492                         Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   486         				return;
   493                         return;
   487         				}
   494                         }
   488 					iIoctlOutstanding = ETrue;
   495                     iIoctlOutstanding = ETrue;
   489 					//check the queue for any other message for this client and call new data if any exist
   496                     //check the queue for any other message for this client and call new data if any exist
   490 					if(!iRecvdMsgQueue.IsEmpty())
   497                     if(!iRecvdMsgQueue.IsEmpty())
   491 						{
   498                         {
   492 						CWapDatagram* msg = iRecvdMsgQueue.First();
   499                         CWapDatagram* msg = iRecvdMsgQueue.First();
   493 						//check the datagram.
   500                         //check the datagram.
   494 						if(msg->IsComplete())
   501                         if(msg->IsComplete())
   495 							{
   502                             {
   496 							NewData(msg);
   503                             NewData(msg);
   497 							}
   504                             }
   498 						else
   505                         else
   499 							{
   506                             {
   500 							//	else notify the client with error.
   507                             //  else notify the client with error.
   501 							//	Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   508                             //  Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   502 							Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   509                             Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   503 							iIoctlOutstanding = EFalse;
   510                             iIoctlOutstanding = EFalse;
   504 							}
   511                             }
   505 
   512 
   506 						}
   513                         }
   507 					break;
   514                     break;
   508 					}
   515                     }
   509 					
   516                     
   510 				case KSOGetMessageParameters:
   517                 case KSOGetMessageParameters:
   511 				//
   518                 //
   512 				// Get the Message Parameters
   519                 // Get the Message Parameters
   513 				//
   520                 //
   514 					{
   521                     {
   515 					if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetMessageParametersIoctlPolicy,"CWapSmsProvider GetMessageParameters Ioctl policy check") != KErrNone))
   522                     if(!iSecurityChecker || (iSecurityChecker->CheckPolicy(wapSmsProviderGetMessageParametersIoctlPolicy,"CWapSmsProvider GetMessageParameters Ioctl policy check") != KErrNone))
   516         				{
   523                         {
   517         				Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   524                         Error(KErrPermissionDenied,MSocketNotify::EErrorIoctl);
   518         				return;
   525                         return;
   519         				}
   526                         }
   520 					iIoctlOutstanding = ETrue;
   527                     iIoctlOutstanding = ETrue;
   521 					//check the queue for any other message for this client and call new data if any exist
   528                     //check the queue for any other message for this client and call new data if any exist
   522 					if(!iRecvdMsgQueue.IsEmpty())
   529                     if(!iRecvdMsgQueue.IsEmpty())
   523 						{
   530                         {
   524 						CWapDatagram* msg = iRecvdMsgQueue.First();
   531                         CWapDatagram* msg = iRecvdMsgQueue.First();
   525 						//check the datagram.
   532                         //check the datagram.
   526 						if(msg->IsComplete())
   533                         if(msg->IsComplete())
   527 							{
   534                             {
   528 							NewData(msg);
   535                             NewData(msg);
   529 							}
   536                             }
   530 						else
   537                         else
   531 							{
   538                             {
   532 							//	else notify the client with error.
   539                             //  else notify the client with error.
   533 							//	Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   540                             //  Note:this can happen if client uses 8-Bit port number for 7-Bit datagram
   534 							Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   541                             Error(KErrGeneral,MSocketNotify::EErrorIoctl);
   535 							iIoctlOutstanding = EFalse;
   542                             iIoctlOutstanding = EFalse;
   536 							}
   543                             }
   537 
   544 
   538 						}
   545                         }
   539 					break;
   546                     break;
   540 					}
   547                     }
   541 
   548 
   542 
   549 
   543 				default:
   550                 default:
   544 				//
   551                 //
   545 				// Unsupported ioctl name
   552                 // Unsupported ioctl name
   546 				//
   553                 //
   547 					{
   554                     {
   548 					// Error gracefully
   555                     // Error gracefully
   549 					Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
   556                     Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
   550 					}
   557                     }
   551 				}
   558                 }
   552 			break;
   559             break;
   553 			}
   560             }
   554 		default:
   561         default:
   555 			// Gracefully error in release build
   562             // Gracefully error in release build
   556 			Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
   563             Error(KErrNotSupported,MSocketNotify::EErrorIoctl);
   557 		}
   564         }
   558 	} // CServProviderBase::Ioctl
   565     } // CServProviderBase::Ioctl
   559 
   566 
   560 
   567 
   561 /**
   568 /**
   562  *  Cancel IOCTL- can only have one outstanding IOCTL at a time
   569  *  Cancel IOCTL- can only have one outstanding IOCTL at a time
   563  */
   570  */
   564 void CWapSmsProvider::CancelIoctl(TUint aLevel,TUint aName)
   571 void CWapSmsProvider::CancelIoctl(TUint aLevel,TUint aName)
   565 	{
   572     {
   566 	LOGWAPPROT1("CWapSmsProvider::CancelIoctl()");
   573     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_CANCELIOCTL_1, "CWapSmsProvider::CancelIoctl()");
   567 
   574 
   568 	if(!iIoctlOutstanding || (aName!=iName) || (aLevel!=KSolWapProv))
   575     if(!iIoctlOutstanding || (aName!=iName) || (aLevel!=KSolWapProv))
   569 		{
   576         {
   570 		Error(KErrNotFound,MSocketNotify::EErrorIoctl);
   577         Error(KErrNotFound,MSocketNotify::EErrorIoctl);
   571 		}
   578         }
   572 	else
   579     else
   573 		{
   580         {
   574 		iIoctlOutstanding=EFalse;
   581         iIoctlOutstanding=EFalse;
   575 		}
   582         }
   576 	} // CWapSmsProvider::CancelIoctl
   583     } // CWapSmsProvider::CancelIoctl
   577 
   584 
   578 
   585 
   579 /**
   586 /**
   580  *  Start the provider- does nothing
   587  *  Start the provider- does nothing
   581  */
   588  */
   582 void CWapSmsProvider::Start()
   589 void CWapSmsProvider::Start()
   583 	{
   590     {
   584 	LOGWAPPROT1("CWapSmsProvider::Start()");
   591     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_START_1, "CWapSmsProvider::Start()");
   585 
   592 
   586 	} // CWapSmsProvider::Start
   593     } // CWapSmsProvider::Start
   587 
   594 
   588 void CWapSmsProvider::AddToQueue(CWapDatagram* aMsg)
   595 void CWapSmsProvider::AddToQueue(CWapDatagram* aMsg)
   589 /**
   596 /**
   590  *  Adding the datagram to received messages queue
   597  *  Adding the datagram to received messages queue
   591  */
   598  */
   592 	{
   599     {
   593 	LOGWAPPROT1("CWapSmsProvider::AddToQueue...");
   600     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_ADDTOQUEUE_1, "CWapSmsProvider::AddToQueue...");
   594 
   601 
   595 	iRecvdMsgQueue.AddLast(*aMsg);
   602     iRecvdMsgQueue.AddLast(*aMsg);
   596 	NewData(aMsg);
   603     NewData(aMsg);
   597 	} // CWapSmsProvider::AddToQueue
   604     } // CWapSmsProvider::AddToQueue
   598 
   605 
   599 
   606 
   600 TInt CWapSmsProvider::SecurityCheck(MProvdSecurityChecker* aSecurityChecker)
   607 TInt CWapSmsProvider::SecurityCheck(MProvdSecurityChecker* aSecurityChecker)
   601  	{
   608     {
   602  	LOGWAPPROT1("CWapSmsProvider::SecurityCheck()");
   609     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDER_SECURITYCHECK_1, "CWapSmsProvider::SecurityCheck()");
   603 
   610 
   604  	iSecurityChecker=aSecurityChecker;
   611     iSecurityChecker=aSecurityChecker;
   605 	return KErrNone;
   612     return KErrNone;
   606  	} // CWapSmsProvider::SecurityCheck
   613     } // CWapSmsProvider::SecurityCheck
   607 
   614 
   608 
   615 
   609 TWapSmsStatusReportScheme CWapSmsProvider::GetStatusReportScheme()
   616 TWapSmsStatusReportScheme CWapSmsProvider::GetStatusReportScheme()
   610 	{
   617     {
   611 	return iStatusReportScheme;
   618     return iStatusReportScheme;
   612 	}
   619     }
   613 
   620 
   614 	
   621     
   615 TWapSmsDataCodingScheme CWapSmsProvider::GetDataCodingScheme()
   622 TWapSmsDataCodingScheme CWapSmsProvider::GetDataCodingScheme()
   616 	{
   623     {
   617 	return iDataCodingScheme;
   624     return iDataCodingScheme;
   618 	}
   625     }
   619 
   626 
   620 
   627 
   621 //
   628 //
   622 // implementation of CWapSmsProviderWrite
   629 // implementation of CWapSmsProviderWrite
   623 //
   630 //
   625 
   632 
   626 /**
   633 /**
   627  *  2 phase constructor
   634  *  2 phase constructor
   628  */
   635  */
   629 CWapSmsProviderWrite* CWapSmsProviderWrite::NewL(CWapSmsProvider& aWapSmsProvider)
   636 CWapSmsProviderWrite* CWapSmsProviderWrite::NewL(CWapSmsProvider& aWapSmsProvider)
   630 	{
   637     {
   631 	LOGWAPPROT1("CWapSmsProviderWrite::NewL");
   638     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_NEWL_1, "CWapSmsProviderWrite::NewL");
   632 	CWapSmsProviderWrite* self = new (ELeave) CWapSmsProviderWrite(aWapSmsProvider);
   639     CWapSmsProviderWrite* self = new (ELeave) CWapSmsProviderWrite(aWapSmsProvider);
   633 	CleanupStack::PushL(self);
   640     CleanupStack::PushL(self);
   634 	self->iMsgSender = CWapSapMessageSender::NewL(aWapSmsProvider.iProtocol->SmsProtocol(), &aWapSmsProvider);
   641     self->iMsgSender = CWapSapMessageSender::NewL(aWapSmsProvider.iProtocol->SmsProtocol(), &aWapSmsProvider);
   635 	CleanupStack::Pop(self);
   642     CleanupStack::Pop(self);
   636 	return self;
   643     return self;
   637 	} // CWapSmsProviderWrite::NewL
   644     } // CWapSmsProviderWrite::NewL
   638 
   645 
   639 
   646 
   640 /**
   647 /**
   641  *  Constructor
   648  *  Constructor
   642  */
   649  */
   643 CWapSmsProviderWrite::CWapSmsProviderWrite(CWapSmsProvider& aWapSmsProvider)
   650 CWapSmsProviderWrite::CWapSmsProviderWrite(CWapSmsProvider& aWapSmsProvider)
   644     :CActive(EPriorityStandard)
   651     :CActive(EPriorityStandard)
   645     ,iWapSmsProvider(aWapSmsProvider)
   652     ,iWapSmsProvider(aWapSmsProvider)
   646     {
   653     {
   647     LOGWAPPROT1("CWapSmsProviderWrite::CWapSmsProviderWrite()");
   654     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_CTOR_1, "CWapSmsProviderWrite::CWapSmsProviderWrite()");
   648 
   655 
   649     CActiveScheduler::Add(this);
   656     CActiveScheduler::Add(this);
   650     } // CWapSmsProviderWrite::CWapSmsProviderWrite
   657     } // CWapSmsProviderWrite::CWapSmsProviderWrite
   651 
   658 
   652 
   659 
   660     delete iDes;
   667     delete iDes;
   661     } // CWapSmsProviderWrite::~CWapSmsProviderWrite
   668     } // CWapSmsProviderWrite::~CWapSmsProviderWrite
   662 
   669 
   663 
   670 
   664 void CWapSmsProviderWrite::Start(RMBufChain& aBufChain, TSockAddr& aAddr)
   671 void CWapSmsProviderWrite::Start(RMBufChain& aBufChain, TSockAddr& aAddr)
   665    	{
   672     {
   666    	LOGWAPPROT1("CWapSmsProviderWrite::Start");
   673     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_START_1, "CWapSmsProviderWrite::Start");
   667    	iWapAddr = reinterpret_cast<TWapAddr&>(aAddr);
   674     iWapAddr = reinterpret_cast<TWapAddr&>(aAddr);
   668    	delete iDes;
   675     delete iDes;
   669    	iDes = NULL;
   676     iDes = NULL;
   670  	TRAPD(err, (iDes = HBufC8::NewL(aBufChain.Length())) );
   677     TRAPD(err, (iDes = HBufC8::NewL(aBufChain.Length())) );
   671  	if(err == KErrNone)
   678     if(err == KErrNone)
   672  		{
   679         {
   673  		TPtr8 desBuf(iDes->Des());
   680         TPtr8 desBuf(iDes->Des());
   674  		desBuf.SetLength(aBufChain.Length());
   681         desBuf.SetLength(aBufChain.Length());
   675  		aBufChain.CopyOut(desBuf, 0);
   682         aBufChain.CopyOut(desBuf, 0);
   676  		// Logging migrated from CWapSmsProvider::GetData
   683         // Logging migrated from CWapSmsProvider::GetData
   677  		LOGSMSIF2("ESOCK READ: \"%S\"", iDes);
   684         OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_START_2, "ESOCK READ: \"%s\"", *iDes);
   678  		LOGSMSIFHEXBUF(_L8("ESOCK READ"), *iDes);
   685 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG)
   679  		LOGSMSIFTIMESTAMP();
   686         LogSmsIfHexBuf(_L8("ESOCK READ"), *iDes);
   680  		}
   687         TBuf<40> timestamp;
   681  	aBufChain.Free();
   688         SmsTimeStampL(timestamp);
   682 
   689         OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS,CSMSSTACKTESTUTILS_PRINTANDTESTDECODEL_1, "%S",timestamp);
   683    	TRequestStatus* status = &iStatus;
   690 #endif
   684    	User::RequestComplete(status, err);
   691         }
   685    	SetActive();
   692     aBufChain.Free();
   686    	} // CWapSmsProviderWrite::Start
   693 
       
   694     TRequestStatus* status = &iStatus;
       
   695     User::RequestComplete(status, err);
       
   696     SetActive();
       
   697     } // CWapSmsProviderWrite::Start
   687 
   698 
   688 
   699 
   689 void CWapSmsProviderWrite::RunL()
   700 void CWapSmsProviderWrite::RunL()
   690 	{
   701     {
   691 	LOGWAPPROT1("CWapSmsProviderWrite::RunL");
   702     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_RUNL_1, "CWapSmsProviderWrite::RunL");
   692 	User::LeaveIfError(iStatus.Int());
   703     User::LeaveIfError(iStatus.Int());
   693 
   704 
   694 	//no need to use cleanup stack
   705     //no need to use cleanup stack
   695 	CWapDatagram* datagram = CWapDatagram::NewL(*iDes);
   706     CWapDatagram* datagram = CWapDatagram::NewL(*iDes);
   696 
   707 
   697 	if (iWapSmsProvider.iDataCodingScheme == EWapSms7BitDCS)
   708     if (iWapSmsProvider.iDataCodingScheme == EWapSms7BitDCS)
   698 		datagram->SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
   709         datagram->SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
   699 	else
   710     else
   700 		datagram->SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
   711         datagram->SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
   701 	
   712     
   702 	if (iWapSmsProvider.iStatusReportScheme == EWapSmsTPSRR)
   713     if (iWapSmsProvider.iStatusReportScheme == EWapSmsTPSRR)
   703 		{
   714         {
   704 		datagram->SetStatusReportScheme(ETPSRRScheme);
   715         datagram->SetStatusReportScheme(ETPSRRScheme);
   705 		}
   716         }
   706 	else
   717     else
   707 		{
   718         {
   708 		datagram->SetStatusReportScheme(EDefaultScheme);
   719         datagram->SetStatusReportScheme(EDefaultScheme);
   709 		} 
   720         } 
   710 		
   721         
   711 	TBuf<KMaxSockAddrSize> addrBuf;
   722     TBuf<KMaxSockAddrSize> addrBuf;
   712 	addrBuf.Copy(iWapAddr.WapAddress());
   723     addrBuf.Copy(iWapAddr.WapAddress());
   713 	datagram->SetToAddress(addrBuf);
   724     datagram->SetToAddress(addrBuf);
   714 	TInt fromPort = iWapSmsProvider.iLocalAddress.WapPort();
   725     TInt fromPort = iWapSmsProvider.iLocalAddress.WapPort();
   715 	datagram->SetPorts(fromPort, iWapAddr.WapPort());
   726     datagram->SetPorts(fromPort, iWapAddr.WapPort());
   716 
   727 
   717 	iMsgSender->SendDatagramL(datagram); // takes ownership of datagram
   728     iMsgSender->SendDatagramL(datagram); // takes ownership of datagram
   718 	} // CWapSmsProviderWrite::RunL
   729     } // CWapSmsProviderWrite::RunL
   719 
   730 
   720 
   731 
   721 TInt CWapSmsProviderWrite::RunError(TInt aError)
   732 TInt CWapSmsProviderWrite::RunError(TInt aError)
   722 	{
   733     {
   723 	LOGWAPPROT1("CWapSmsProviderWrite::RunError");
   734     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_RUNERROR_1, "CWapSmsProviderWrite::RunError");
   724 	iWapSmsProvider.Error(aError, MSocketNotify::EErrorSend);
   735     iWapSmsProvider.Error(aError, MSocketNotify::EErrorSend);
   725 	return KErrNone;
   736     return KErrNone;
   726 	} // CWapSmsProviderWrite::RunError
   737     } // CWapSmsProviderWrite::RunError
   727 
   738 
   728 
   739 
   729 void CWapSmsProviderWrite::DoCancel()
   740 void CWapSmsProviderWrite::DoCancel()
   730 	{
   741     {
   731 	LOGWAPPROT1("CWapSmsProviderWrite::DoCancel");
   742     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWAPSMSPROVIDERWRITE_DOCANCEL_1, "CWapSmsProviderWrite::DoCancel");
   732 	TRequestStatus* status = &iStatus;
   743     TRequestStatus* status = &iStatus;
   733 	User::RequestComplete(status, KErrCancel);
   744     User::RequestComplete(status, KErrCancel);
   734 	} // CWapSmsProviderWrite::DoCancel
   745     } // CWapSmsProviderWrite::DoCancel
   735 
   746 
   736 
   747 
   737 // EOF - WS_PRVDR.CPP
   748 // EOF - WS_PRVDR.CPP