×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    10

    SMS Receiver (code misunderstanding)

    Hi,

    I need to listen for incoming SMS events in my app. As an example I took a look at SMS Receiver on wiki
    http://wiki.forum.nokia.com/index.php/SMS_Receiver

    However, I didn't clearly understand what is going on there Particularly - how MSMSRecCallBack class is related to CSMSReceiver.

    Code:
    class MSMSRecCallBack 
    {
    public:
    	virtual void GotSMSMessageL(const TDesC& aMessage) = 0;
    };
     
     
    class CSMSReceiver : public CBase, MMsvSessionObserver
        {
    ..........
    Where GotSMSMessageL is implemented? CSMSReceiver doesn't derive from MSMSRecCallBack, so I can't understand what does declaration of MSMSRecCallBack bring?
    Could someone please explain the logic of code in that example. Thanks!

    -Aleksandr

  2. #2
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    99

    Re: SMS Receiver (code misunderstanding)

    MSMSRecCallBack is example of base class for your own message observer.
    If you like to, you can write something like this:
    Code:
    class MyOwnObserverRealization: public MSMSRecCallBack 
    {
    
    virtual void GotSMSMessageL(const TDesC& aMessage){
      // here you can do anything read only with message.
    }
    
    };

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    10

    Re: SMS Receiver (code misunderstanding)

    Aha, so as I understand this MSMSRecCallBack interface is just additional feature in this example, but not mandatory thing? In this case I can't figure out what kind of benefits this Receiver -> Callback observer architecture give me? If we take a look at HandleEntryL in Receiver:

    Code:
    void CSMSReceiver::HandleEntryL(TMsvId& aEntId)
    {	
    	...................
    
            SmsMtm->SetCurrentEntryL(entry);
    	SmsMtm->LoadMessageL();
     
    	HBufC* BodyBuffer = HBufC::NewLC(SmsMtm->Body().DocumentLength());
    	TPtr BodyPoint(BodyBuffer->Des());
     
    	SmsMtm->Body().Extract(BodyPoint,0,SmsMtm->Body().DocumentLength());
     
    	iObserver.GotSMSMessageL(*BodyBuffer);
     
    	...................		
    }
    So, is it ok to analyse SMS body (or whatever I want to do with SMS) just inside HandleEntryL instead of calling iObserver.GotSMSMessageL ?

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

    Re: SMS Receiver (code misunderstanding)

    Indeed. If you see the declaration of a method and the invocation of a method in the same code, that is a local, optional thing/solution.
    The "real" things happen in MMsvSessionObserver::HandleSessionEventL.

Similar Threads

  1. AT Command for check sms receiver operator
    By z3dd in forum General Messaging
    Replies: 0
    Last Post: 2009-06-23, 20:04
  2. Replies: 106
    Last Post: 2009-05-11, 05:53
  3. Replies: 2
    Last Post: 2007-11-10, 13:19
  4. Send SMS Problem. Cannot Get SMSC Address. Due to Strange SIM Card?
    By cksong in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-07-02, 16:13
  5. code SMS to send the information of the signal strentgh
    By Léo in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-10-30, 07:56

Posting Permissions

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