×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Unhappy TSmsAddr SetTextMatch

    Hi, i'm trying sockets to recieve sms. Looks like SetTextMatch(txt) function don't work with '*' or '?' patterns. It's just compare sms body with matchText from beginning. That's looks strange and useless.
    Can i use patterns to filter incoming sms? Can i use multiple patterns?

    Edit: Looks like same problem described there, but answer in chinese
    Last edited by truf; 2008-01-17 at 15:37. Reason: chinise -> chinese

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

    Re: TSmsAddr SetTextMatch

    Quote Originally Posted by truf View Post
    It's just compare sms body with matchText from beginning. That's looks strange and useless.
    It is usful for capturing messages with special prefixes. Have you seen this one: http://wiki.forum.nokia.com/index.php/SMS_Utilities_API ?
    Can i use patterns to filter incoming sms? Can i use multiple patterns?
    My guess would be that you can have multiple sockets, and one prefix per socket.

  3. #3
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    It is usful for capturing messages with special prefixes. Have you seen this one: http://wiki.forum.nokia.com/index.php/SMS_Utilities_API ?
    Yes, i'm talking about that. In that sample if you use _LIT(KTag1, "*H") or _LIT(KTag1, "?H") you will catch only messages "*Hi" or "?Hello", not "Hello" or "SometHing". So that function looks like useless toy.

    My guess would be that you can have multiple sockets, and one prefix per socket.
    I need to catch about 10 sms commands. I think thats a bit excess. Should i use 10 active objects?

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

    Re: TSmsAddr SetTextMatch

    If you carefully design the commands, one prefix could be enough.
    For example:
    TrufCommand HelloWorld
    TrufCommand Hello to <n> People
    TrufCommand GetTime <location>
    TrufCommand Call <telno>
    ...
    -style messages can be captured via matching with "TrufCommand".

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    Looks like thats the only way.
    But may be i can do following:
    1. Intercept all sms
    2. Process sms body
    3. leave non-command sms in Inbox

    I can easy implement 1 and 2 by using KNullDesC as matchText in SetTextMatch(). But is any way to pass captured sms to messaging server? I don't like idea of creation entries in inbox and events in log engiene manually.

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    282

    Re: TSmsAddr SetTextMatch

    Quote Originally Posted by truf View Post
    Looks like thats the only way.
    But may be i can do following:
    1. Intercept all sms
    2. Process sms body
    3. leave non-command sms in Inbox

    I can easy implement 1 and 2 by using KNullDesC as matchText in SetTextMatch(). But is any way to pass captured sms to messaging server? I don't like idea of creation entries in inbox and events in log engiene manually.
    Hi,

    I was working on a very similar project and had to manually create inbox entries for incoming sms's. Heres is the code that i used. I havent declared varibles but i suppose that u can understand what they mean. One point to ponder. if the incoming message from an existing contact then the from entry should contains the contact lable. The code belows does exactly that:

    CSmsMessage &iMsg= //some message;
    TPtrC from=iMsg.ToFromAddress();
    HBufC * frmName=NULL;
    CContactIdArray * matches=iContactEngine.MatchPhoneNumberL(from,8);
    CleanupStack::PushL(matches);
    if(matches->Count()>0){
    CPbkContactItem * itm=iContactEngine.ReadContactL(matches[0][0]);
    CleanupStack::PushL(itm);
    frmName=itm->GetContactTitleOrNullL();
    CleanupStack::PopAndDestroy(itm);
    iContactEngine.CloseContactL(matches[0][0]);
    }
    CleanupStack::PopAndDestroy(matches);

    iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox
    iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
    CSmsHeader& iHeader = iSmsMtm->SmsHeader();
    iHeader.SetFromAddressL(from);

    CSmsBufferBase & smsbuffer=iMsg.Buffer();
    HBufC * msgBuffer=HBufC::NewLC(smsbuffer.Length());
    TPtr ptr=msgBuffer->Des();
    smsbuffer.Extract(ptr,0,smsbuffer.Length());


    CRichText& body = iSmsMtm->Body();
    body.Reset();
    body.InsertL(0, *msgBuffer);

    CMsvEntry & centry = iSmsMtm->Entry();
    TMsvEntry entry = centry.Entry();
    entry.SetInPreparation(EFalse);
    entry.SetVisible(ETrue);
    entry.iDate.HomeTime();
    entry.iDate= iMsg.Time();
    entry.iDescription.Set(*msgBuffer);

    if(frmName)
    {entry.iDetails.Set(*frmName);
    delete frmName;
    }
    else entry.iDetails.Set(from);

    entry.SetUnread(ETrue);
    iSmsMtm->Entry().ChangeL(entry);
    iSmsMtm->SaveMessageL();
    CleanupStack::PopAndDestroy(msgBuffer);


    CPlainText * txt=CPlainText::NewL();
    CMsvStore * store=centry.EditStoreL();
    CSmsHeader * header=CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*txt);
    header->SetFromAddressL(from);
    header->Deliver().SetServiceCenterTimeStamp(iMsg.Time());
    header->StoreL(*store);
    store->CommitL();
    delete store;/**/

  7. #7
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    Thank you vaibhavjain, your code real help me.

  8. #8
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    Looks like last piece of code
    CPlainText * txt=CPlainText::NewL();
    CMsvStore * store=centry.EditStoreL();
    CSmsHeader * hdr=CSmsHeader::NewL(CSmsPDU::ESmsDeliver,*txt);
    hdr->SetFromAddressL(*aPhone);
    hdr->Deliver().SetServiceCenterTimeStamp(aTime);
    hdr->StoreL(*store);
    store->CommitL();
    delete store;
    doesn't work propertly. I think it's should mark sms as incoming, by adding SmsPDU::ESmsDeliver header. Bcs in other case you cant replay or call to sender number then open such sms.

    That code does't do anything if i put it after iSmsMtm->SaveMessageL(); and crash program if i put it before. Also, are you sure all instances destroyed and there are no memory leaks?

  9. #9
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    OK, solved
    Last edited by truf; 2008-01-20 at 12:00.

  10. #10
    Regular Contributor
    Join Date
    May 2003
    Posts
    91

    Re: TSmsAddr SetTextMatch

    Quote Originally Posted by truf View Post
    OK, solved
    How can you do it? Could you tell me?

  11. #11
    Nokia Developer Expert
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    1,355

    Re: TSmsAddr SetTextMatch

    Code:
    void CSmsHandler::CreateSmsLD(TDesC* aPhone, TDesC* aText, const TTime aTime)
    {
    	if (aPhone)
    		{
    		CleanupStack::PushL(aPhone);
    		
    		 if (aText)
    			 {
    			 CleanupStack::PushL(aText);
    			 
    			 iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox
    			 iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
    			 CSmsHeader& header = iSmsMtm->SmsHeader();
    			 header.Message().SetTime(aTime);
    			 header.SetFromAddressL(*aPhone);			 
    			 CRichText& body = iSmsMtm->Body();
    			 body.Reset();
    			 body.InsertL(0, *aText);
    
    			 CMsvEntry & centry = iSmsMtm->Entry();
    			 TMsvEntry entry = centry.Entry();
    			 entry.SetInPreparation(EFalse);
    			 entry.SetVisible(ETrue);
    			 entry.iDate = aTime;
    					 
    			 entry.iDescription.Set(body.Read(0, 20));
    			 TPtrC title;
    			 TRAP_IGNORE(title.Set( iPhoneBookHandler-> GetContactNameByPhoneL(aPhone))); //thats my object for PhoneBook searching
    		
    			 if(title.Length() > 0)
    				 {
    				 	entry.iDetails.Set(title);				 
    				 }
    				 else entry.iDetails.Set(*aPhone);
    			 
    			 iSmsMtm->AddAddresseeL(*aPhone, entry.iDetails);
    			 
    			 entry.SetUnread(ETrue);
    			 iSmsMtm->Entry().ChangeL(entry);
    			 
    			 iSmsMtm->SaveMessageL();
    			 
    			 // Now save the original message text
    			    CMsvStore* messageStore = iSmsMtm->Entry().EditStoreL();
    			    CleanupStack::PushL( messageStore );
    
    			    // To make programmatically created message display "From", not "To"
    			    // in the Messaging application, it is needed to store the ESmsDeliver PDU
    			    // into the message header
    			    CSmsHeader* hdr = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, body );
    			    CleanupStack::PushL( hdr );
    			    hdr->SetFromAddressL(*aPhone);	
                               hdr->Deliver().SetServiceCenterTimeStamp(aTime);		    
    			    hdr->StoreL( *messageStore );
    			    CleanupStack::PopAndDestroy( hdr );
    			    messageStore->StoreBodyTextL( body );
    				messageStore->CommitL();				
    				CleanupStack::PopAndDestroy( messageStore );   
    				
    			 CleanupStack::PopAndDestroy(aText);
    			 }
    		 
    		 CleanupStack::PopAndDestroy(aPhone);
    		}
    }
    Frankly, i did't remember what was my problem. But i find what i use that func and it's work ok.
    Last edited by truf; 2009-01-05 at 19:07. Reason: added hdr->Deliver().SetServiceCenterTimeStamp(aTime);

  12. #12
    Regular Contributor
    Join Date
    May 2003
    Posts
    91

    Re: TSmsAddr SetTextMatch

    Thanks, But there are two problems, did not reply options, and time will be empty!
    is't work well in your app?

  13. #13
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    119

    Re: TSmsAddr SetTextMatch

    Quote Originally Posted by truf View Post
    Yes, i'm talking about that. In that sample if you use _LIT(KTag1, "*H") or _LIT(KTag1, "?H") you will catch only messages "*Hi" or "?Hello", not "Hello" or "SometHing". So that function looks like useless toy.


    I need to catch about 10 sms commands. I think thats a bit excess. Should i use 10 active objects?
    Truf,
    Im trying to do the sms_utilities_api, but im not really sure where do i apply the code (Void SMSRead(), Void RunL()). SOry im kinda new in this carbide. and for smssendL(), do i really need to put this, if i just want to block sms just through text? ive done the smssilent. so when the message enter, it pop up a query showwing the message, but the message will not be stored inside inbox. is that true how the program work?

    hope to get your reply soon...

  14. #14
    Registered User
    Join Date
    Jan 2012
    Posts
    110

    Re: TSmsAddr SetTextMatch

    How to get all the messages from the socket, truf?

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

    Re: TSmsAddr SetTextMatch

    Have you read #5 in this thread? KNullDesC is the empty text.

Similar Threads

  1. TSmsAddr & pattern matching : address ?
    By spielchief in forum Symbian
    Replies: 0
    Last Post: 2007-04-16, 20:23

Posting Permissions

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