×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    How to read SMS via Socket and get into inbox

    I have an app that receives commands via SMS and also has to filter all incoming SMS based on A-Party number.
    Since it is fundamental to process the SMS before the user is alerted, I use the "SMS Utilities API".

    The problem I have is that all SMS "captured" via sockets do not appear in the inbox. Since I am capturing all of them to filter based on number and pattern, no SMS ever gets to the user.

    The code I use is similar to the on in http://wiki.forum.nokia.com/index.php/SMS_Utilities_API :

    Code:
    void CSMSObserver::ConstructL()
    	{
    	TBuf8<2> matchTag;
    	
    	CActiveScheduler::Add(this);
    	
    	iFs.Connect();
    	iSocketServer.Connect();
    	
    	matchTag.Zero();	//	Empty, to filter all SMS
    	TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol);
    	if(!err)
    		{
    		TSmsAddr smsAddr;
    		smsAddr.SetSmsAddrFamily(ESmsAddrMatchText);
    		smsAddr.SetTextMatch(matchTag);
    		TInt bindErr = iSocket.Bind(smsAddr);
    		if(!bindErr)
    			{
    			iPckgBuf() = KSockSelectRead;
    			iSocket.Ioctl(KIOctlSelect, iStatus, &iPckgBuf, KSOLSocket);
    			SetActive();
    			}
    		}
    	}
    
    
    void CSMSObserver::RunL()
    	{
    	if(!isRead)
    		{
    		TBuf<KMaxProMsgLength> msgContents;
    		TGsmSmsTelNumber msisdn;
    
    		RSmsSocketReadStream readStream(iSocket);
    		CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
    
    		CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver, smsBuffer);
    		CleanupStack::PushL(smsMessage);
    		smsMessage->InternalizeL(readStream);
    		readStream.Close();
    		smsMessage->Buffer().Extract(msgContents, 0, smsMessage->Buffer().Length());
    		smsMessage->ParsedToFromAddress(msisdn);
    		TInt filter_result = FilterIncomingSMS(msisdn.iTelNumber, msgContents);
    		switch(filter_result)
    			{
    			case 0:
    				iCallBack->ProtocolSMSNotification(msisdn.iTelNumber, msgContents);
    				break;
    			case 1:         //      SMS goes through
    				break;
    			case 2:		//	SMS blocked
    				break;
    			}
    		iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, NULL, KSolSmsProv);
    		isRead = ETrue;
    		CleanupStack::PopAndDestroy(smsMessage);
    		}
    	else
    		{
    		iSocket.Ioctl(KIOctlSelect, iStatus, &iPckgBuf, KSOLSocket);
    		isRead = EFalse;
    		}
    	SetActive();
    	}
    What do I need to do to get SMS that pass the filter (red line above) to continue their way to Inbox?
    ----------------------------------------------
    Every journey starts with a small step.

  2. #2
    Super Contributor
    Join Date
    Jun 2005
    Location
    Berlin
    Posts
    721

    Re: How to read SMS via Socket and get into inbox

    Hello,


    I haven't used socket to catch sms yet. But the code
    Code:
    iSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, NULL, KSolSmsProv);
    looks like, that the SMS is flagged as read already.


    Try comment this setting, if it doesn't sent by your parter's number.

    And check again, if new SMS does appear in your inbox?


    regards,

    Pai
    Symbian && Android && iPhoneOS

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to read SMS via Socket and get into inbox

    People sometimes simply forget to do that ioctl, and it results in delivering the given messages on the next reboot of the phone, so it is probably not the best way.

    Juannoguera: have you considered searching for inbox sms in the Wiki?

  4. #4
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: How to read SMS via Socket and get into inbox

    Does not seem to be issue with iSocket.Ioctl().
    I did search the Wiki and other forums before but could not find any relevant entry. Only http://wiki.forum.nokia.com/index.php/Create_Local_SMS
    but I thought that there had to be a simpler way than just inserting a SMS in Inbox manually.
    ----------------------------------------------
    Every journey starts with a small step.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to read SMS via Socket and get into inbox

    As far as I know, there is no simpler way than doing it manually.
    You can experiment with taking advantage of that you actually have a complete CSmsMessage object, according to the SDK Help you may speed up creating the TMsvEntry object for example (assuming that TSmsUtilities is also part of the plug-in pack, I have not checked).

  6. #6
    Regular Contributor
    Join Date
    Jun 2007
    Posts
    77

    Re: How to read SMS via Socket and get into inbox

    Hi, i am also looking a perfect solution for this case. SMS Utilities API is not really working for filter the sms in 3rd edition FP1 or later. Since it delete the incoming sms from the inbox but can't able to stop the vibration or msg tone. So that socket listener is the solution and we can move the filtered sms to inbox from the linstner. Please correct me, if am wrong.

    Thanks
    Jobin

  7. #7
    Registered User
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60

    Re: How to read SMS via Socket and get into inbox

    Try to use CSmsClientMtm instead of CSmsMessage.
    Code:
    mtmregistry = CClientMtmRegistry::NewL(session);
    smsmtm = STATIC_CAST( CSmsClientMtm*, mtmregistry->NewMtmL( KUidMsgTypeSMS ) );
    CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
    CleanupStack::PushL(smsBuffer);
    RSmsSocketReadStream readStream(iSocket);
    smsmtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId);
    smsmtm->CreateMessageL(KUidMsgTypeSMS.iUid);
    smsmtm->SmsHeader().Message().InternalizeL(readStream);
            
    sender.Copy(iSmsMtm->SmsHeader().FromAddress());
    if (SenderOk(sender) == FALSE)
       smsmtm->Entry().DeleteL(smsmtm->Entry().EntryId());
    else
    {
    TMsvEntry entry = smsmtm->Entry().Entry();
    entry.SetInPreparation(EFalse);
    entry.iDetails.Set(sender);
    entry.SetVisible(ETrue);
    entry.iDate.HomeTime();
    entry.SetUnread(ETrue);
    iSmsMtm->Entry().ChangeL(entry);
    smsmtm->SaveMessageL();
    }

  8. #8
    Regular Contributor
    Join Date
    Jun 2007
    Posts
    77

    Re: How to read SMS via Socket and get into inbox

    Wiki source code (http://wiki.forum.nokia.com/index.php/Create_Local_SMS) is not really working for the sms filter. Its working fine for push the sms to inbox. But inbox showing the the number only instead address book name. Also there is no 'replay' option.badzio, ur source code also looks like same, but i didn't try. how is the above cases? Any alternate solution?

    Jobin

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to read SMS via Socket and get into inbox

    Does the message you get contain "To:" or "From:" when displayed?
    For the name, you see what you set in TMsvEntry::iDetails. Use CPbkContactEngine::MatchPhoneNumberL+CPbkContactItem::GetContactTitleL.

  10. #10
    Registered User
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    60

    Re: How to read SMS via Socket and get into inbox

    You must manually fetch phonebook, find sender number, if found contact than get contact name and set in line entry.iDetails.Set(sender)

  11. #11
    Regular Contributor
    Join Date
    Jun 2007
    Posts
    77

    Re: How to read SMS via Socket and get into inbox

    yes. We can fetch the sender name from address book and set it into the TMsvEntry::iDetails. But it doesn't set the 'replay' option . For that i have tried CSmsHeader::SetFromAddressL(entry.iDetails) and its showing the replay option. But this also failed to set the replay option, suppose entry.iDetails is a address name like 'care' instead of a mobile number '+91xxxxxxxxxx'. And when i open "Message Details" menu it shows me following details:

    From Care //missed the number
    Subject Care
    Date 19/10/2009
    Time 5:35 am
    Type Text message

    Its seems From missed the number Care<+91xxxxxxxxx> . Plz tell me how to resolve it.

  12. #12
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to read SMS via Socket and get into inbox

    If you happen to use S60 3rd, S60 3rd MR or S60 3rd FP1 SDK-s, search for *fromaddress* (the *-s are important) in the SDK Help, and you will get a couple things where you can experiment with setting the sender address (or just checking if it is set to something already in case of your message and in case of a 'traditional' one).

  13. #13
    Regular Contributor
    Join Date
    Jun 2007
    Posts
    77

    Re: How to read SMS via Socket and get into inbox

    Solved. I have created CSmsHeader with the CSmsMessage and storing it in the the CMsvStore. Thanks for the replay.

  14. #14
    Registered User
    Join Date
    Oct 2009
    Posts
    2

    Re: How to read SMS via Socket and get into inbox

    Hi, i am also looking a solution for get the replay option with contact book name. I have tried to follow your scenario without success. Tell me what i have missed?
    Last edited by symbianhelp; 2009-10-30 at 07:00.

  15. #15
    Registered User
    Join Date
    Oct 2009
    Posts
    2

    Re: How to read SMS via Socket and get into inbox

    hi, no more replay? please give me some clues.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×