Hello developers,
please leave here a clue where I could make a mistake:
The waiting for incoming sms is triggered by method Idle() in CActive class with EPriorityStandard:
The SocketListen() looks like this:Code:void CSmsService::Idle() { if ( !IsActive() ) { iRead=ETrue; iFs.Connect(); iSocketServer.Connect(); //User::After(1000000); //I tried both versions SocketListen(); } }
And the problem is that the execution stops - freezes on the line iSmsMessage->InternalizeL(readStream). That is understandable as there was no incoming sms yet. The RunL() is triggered and I do not know why.Code:void CSmsService::SocketListen() { _LIT(KTag, ""); TBuf8<2> matchTag; matchTag.Copy(KTag); //Opens a socket by creating a new subsession to the socket server. TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol); if(err==KErrNone) { TRequestStatus iStatus; TSmsAddr smsaddr; // App. listens for sms msgs with some special tag in it. smsaddr.SetSmsAddrFamily(ESmsAddrMatchText); smsaddr.SetTextMatch(matchTag); TInt BindErr = iSocket.Bind(smsaddr); if(BindErr == KErrNone) { iPckgBuf() = KSockSelectRead; //Applies an asynchronous I/O control operation on a socket. iSocket.Ioctl( KIOctlSelect,iStatus, &iPckgBuf, KSOLSocket); iRead=ETrue; SetActive(); } } }
Code:void CSmsService::RunL() { if(iStatus == KErrNone) { if(iRead && iGlobalProperties.GetSecurePhone() ) { 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. iSmsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer); //Internalises data from stream to CSmsMessage iSmsMessage->InternalizeL(readStream); readStream.Close(); //Extracting the received message to a buffer iSmsMessage->Buffer().Extract(iBuf,0,iSmsMessage->Buffer().Length()); iSocket.Ioctl( KIoctlReadMessageSucceeded,iStatus, &iPckgBuf, KSolSmsProv); //Printing the received Message. //CAknInformationNote* note122=new(ELeave) CAknInformationNote; //note122->ExecuteLD(iBuf); iRead=EFalse; SetActive(); CleanupStack::PopAndDestroy(smsBuffer); } } }




