Preprocessing the incoming message

Start this code example (ready to install sis file included) and while the demo program is running all the incoming messages will be appended with the ".Changed" text.


For emulator trials, the demo program has an option to simulate the incoming message.

Handling the incoming messages is rather simple - you just need to open the connection to CMsvSession and handle the session events. It becomes more difficult if you'd like to somehow preprocess the incoming message, for example "censor out" the rude words, which could be a nice feature for children-targeted phones. There are two major problems on the way:

1. You can easily change the sender number and description of the received message by manipulating its index TMsvEntry. However, the message text might be locked by the Messaging server for quite a long time and you might not be able to change it. I guess Messaging creators didn't expect that somebody would need to change the incoming SMS text and did not care to guarantee the certain "unlock time". The solution to it is to clone the original message, change the cloned message text and then delete the original message. And here the second problem comes in.

2. When you manually create the SMS message in the Inbox, the Messaging application displays it as the outgoing message

The trick is to set the ESmsDeliver PDU in the CSmsMessage:

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* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *richText );
CleanupStack::PushL( header );
header->StoreL( *messageStore );

Note, that this trick also opens the way for telling the user just about anything important in the familiar, simple and effective way. You might have some client running in the background. This client might simulate the usual incoming sms, when e.g. stocks are going up and it is time to buy them. Another funny (and profitable?) example could be to make your cool python-enabled S60 web-server guestbook script to deliver your mobile web-site visitor comments directly to your Inbox.

Everybody is welcome to simplify this example or make it work with MMSes also. Feel free to submit your code examples and gain all the fame. Enjoy!

P.S.
This example was created because of Hameed's request that I found interesting. If you'd like to see some other feature demonstrated, please, ask, and I'll try to invent something.

AttachmentSize
SmsModifier.zip20.58 KB

Comments

Thta's just an example

Edcruise, this example is just a demo, proof of concept. And it is a demo on how to preprocess the message, not on how to make a reliable application.

Therefore, this demo was never intended to handle more than a single message at a time. It would be very kind of you, if you could create a working multiple message demo and post it here :)

Try running from fully loaded emulator

I am not sure if you can use the messaging service from the console application, if you don't somehow start it yourself

Hi, Kiran Try asking on the

Hi, Kiran

Try asking on the forum. People reply there more, than in the blog comments

Check the Forum Nokia

Check the Forum Nokia Getting Started pages. Forum Nokia has a number of good papers for starters. Not sure about the books. Hopefully somebody else could provide an advice about the books for starters.

Try asking on the forum. People reply there more, than in the blog comments

:-)

Thanks for this tip "The trick is to set the ESmsDeliver PDU in the CSmsMessage:" Artem :-)
I was trying to do it from longtime :-)

MMSes: I'll be doing that too very soon, will post code here. :)

Looking forward to your post!

Unfortunately the Symbian Messaging documentation is quite.. well, quite complex. Sometimes you have to dig the documentation really deep. If you search for the TSmsPDUType in the SDK docs, there is all the information. However it took from me couple of days until I managed to locate it :)

MMSes: I'll be doing that too very soon, will post code here. :)

Just great! I am looking forward to it!