Hi,
my goal is to intercept incoming sms (for example with a certain starting pattern) before it reaches the Native SMS Application.
I have tried the SMS via sockets example from Wiki. It works but if I try to push any button when the application is running... it crashes after few seconds.
Here is the code:
Using my logger I observed that the RunL is called when a button is pushed.Code:void CSMSEngine::SocketListen() { _LIT(KTag, "#"); TBuf8<2> matchTag; matchTag.Copy(KTag); LogSMS(_L("Start")); //Opens a socket by creating a new subsession to the socket server. TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol); LogSMS(_L("Socket opened")); if(err==KErrNone) { LogSMS(_L("KErrNone")); TRequestStatus iStatus; TSmsAddr smsaddr; // App. listens for sms msgs with some special tag in it. smsaddr.SetSmsAddrFamily(ESmsAddrMatchText); smsaddr.SetTextMatch(matchTag); //smsaddr.SetSmsAddrFamily(ESmsAddrApplication16BitPort); //smsaddr.SetPort(16500); TInt BindErr = iSocket.Bind(smsaddr); LogSMS(_L("Binded")); if(BindErr == KErrNone) { iPckgBuf() = KSockSelectRead; //Applies an asynchronous I/O control operation on a socket. iSocket.Ioctl( KIOctlSelect,iStatus, &iPckgBuf, KSOLSocket); iRead=ETrue; LogSMS(_L("SetActive")); SetActive(); } } } // ----------------------------------------------------------------------------- // CSMSEngine::RunL() // Gets hit everytime a message with the 'tag' arrives // ----------------------------------------------------------------------------- // void CSMSEngine::RunL() { LogSMS(_L("RunL")); if(iRead) { LogSMS(_L("iRead")); CSmsBuffer *smsBuffer = CSmsBuffer::NewL(); CleanupStack::PushL(smsBuffer); //Stream that reads a CSmsMessage object across a socket. RSmsSocketReadStream readStream(iSocket); //Allocates and creates a CSmsMessage //ESmsDeliver-SMS-DELIVER, sent from service center to Mobile Station. LogSMS(_L("ReadStream Created")); iSmsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer); //Internalises data from stream to CSmsMessage LogSMS(_L("iSmsMessage Created")); iSmsMessage->InternalizeL(readStream); readStream.Close(); LogSMS(_L("SmsMessage Readed")); //Extracting the received message to a buffer iSmsMessage->Buffer().Extract(iBuf,0,iSmsMessage->Buffer().Length()); LogSMS(_L("buffer extracted")); iSocket.Ioctl( KIoctlReadMessageSucceeded,iStatus, &iPckgBuf, KSolSmsProv); LogSMS(_L("Ioctl")); //Printing the received Message. LogSMS(iBuf); CAknInformationNote* note122=new(ELeave) CAknInformationNote; note122->ExecuteLD(iBuf); iRead=EFalse; SetActive(); CleanupStack::PopAndDestroy(smsBuffer); } }
How I can avoid that?
I just want to send the application in background and push the other buttons
Thanks in advance







