开发者

How can I send different SMS' to multiple recipients in a loop

I'm using Symbian C++ to create my code, I'm using S60 5th Ed SDK

I want to know how to send different messages - Their body text not the same - to multiple recipients in a for-loop ?

I've tried the example below, but when I try to use it in a loop it crashes due to ActiveObjects properties, as I should wait to AO to finish before calling it again.

Sending_SMS_in_S60_3rd_Edition_MTM

Below is example of what I need to do:

SendSMSL();     // **I call this function once to start the process**

// **iRecepients is a CDesCArray contains phone numbers**
// ** iSMSBody is a CDesCArray contains each contact SMS body text**

void CSMS::SendSMSL()
  {

  if(iRecepients->Count() >= 1) 
    {
        TInt x = iRecepients->Count()-1;
        TInt y = iSMSBody->Count()-1; 

        // **If the sms validating and scheduling succeeded then delete last item from both arrays**
        if(iSMSHandler->SendL((*iRecepients)[x],(*iSMSBody)[y])
            {
                iRecepients->Delete(x);
                iSMSBody->Delete(y);    
            }
    }
 }

Now, in the code above I call iSMSHandler->SendL() which send sms using AO, and in iSMSHandler object RunL() function, I call back the functio开发者_如何学JAVAn above CSMS::SendSMSL() , which in turn checks if there is still anymore iRecepients elements and then call again iSMSHandler->SendL() AO , and keeps this way till no more iRecepients.

Looking forward to hear your feedback on the modification above.

Many thanks in advance.


The link you posted doesn't work for me so I can't see the rest of the code.

Assuming that iSmsHandler is a class that uses active objects to send SMS messages, I see several issues with your loop.

1) You need to wait for the first asynchronous SendL to complete before you can issue the next SendL 2) The buf variable can not go out of scope until the SendL completes. (This may be the reason for your crash)

I suggest that you keep the textbuffer somewhere else, like together with iSmsHandler, and then code the active object that is called when SendL completes to issue the next SendL.

All of this is guesses since I have no idea what class iSmsHandler is....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜