Sending and receiving SMS (silent)
This code snippet describes how to send and receive SMS silently using Symbian C++.
This code snippet describes how to send short message (SMS) and handling silent SMS. It shows in a single class how we can handle both SMS sending and receiving. When this demo application runs on any Symbian device, it monitors the SMS socket and intercept the message if it has "secret" word in it. If it has no "secret" word then it works without any effect.
In the following code snippet KSMSPrefixString has been specified as _LIT8(KSMSPrefixString, "secret"). If you want to monitor for other word you could change it.
// Open SMS socket
// Set SMS prefix - only intercept SMS messages starting with a particular string
Handling both Sender and Receiver
CENgineSMSSendReceive class handles both sending and receiving. This class is derived from MSecretSMSReceiverObserver and MSecretSMSSenderObserver class. When we send a SMS then the result is inform with a call back mechanism by MSecretSMSSenderObserver class. In turns, engine class inform the UI class with MEngineObserverObserver. When message is delivered or new secret message comes then the call back function inform the UI by creating a note.
class CENgineSMSSendReceive : public CBase, public MSecretSMSReceiverObserver, public MSecretSMSSenderObserver
// from MSecretSMSReceiverObserver
void NewSecretSmsReveicedL( const TDesC& aSMSMsg );
// from MSecretSMSSenderObserver
void SmsSendResult( TInt aError );
CENgineSMSSendReceive(MEngineObserverObserver & aEngineObserverObserver);
MEngineObserverObserver & iEngineObserverObserver;
Compiling and testing
The code was tested with N97, it was a quick demo for discussion purpose. If you wish to send sms then change the number in the following line of ENgineSMSSendReceive.cpp file. numbers->AppendL(_L("+35840ADDNumber")); // TODO
Download the example for Symbian phones: Media:SilentSMSSendReceive.zip