×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    95

    Unhappy blocking outgoing sms

    Hi ,

    I want to create the block the outgoing sms for a particular number.

    So the approach I follow is
    1) Retrieve the number and body.
    2) Then Delete the sms.

    I am able to acheive 1 successfully but before the code reaches for point 2 my sms is sent from outbox.
    so I am not able to delete the sms.


    I am attaching my code snippet

    void CSmsMmsObserver::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)
    {
    switch(aEvent)
    {
    case EMsvEntriesChanged:
    {
    // Entry id is obtained from the session event arguments.
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );

    // We are interested in messages that are created in outbox.
    if ( *entryId != KMsvGlobalOutBoxIndexEntryId )
    {
    break;
    }

    // We take the created entries into a selection
    CMsvEntrySelection* newEntries =
    STATIC_CAST( CMsvEntrySelection*, aArg1 );

    // Process each created entry.
    for ( TInt i( 0 ); i < newEntries->Count(); i++ )
    {
    // We are interested in SMS messages.
    if ( ( iSession->GetEntryL( newEntries->At( i ) ) )
    ->Entry().iMtm == KUidMsgTypeSMS )
    {
    // Add the entry to the selection of all received messages.
    iSelection->AppendL( newEntries->At( i ), 1 );

    // Set received messages visible.
    MessageSendL( newEntries->At( i ) );// Here is my function to Reteive body and number of
    //outgoing sms and Delete

    }
    }

    break;





    }


    void CSmsMmsObserver::MessageSendL(TMsvId aEntryId)
    {
    LogNew(_L("\n MessageSendL"));
    {
    TInt MySMS;
    MySMS=0;
    CMsvEntry* entry = iSession->GetEntryL(aEntryId);
    CleanupStack::PushL(entry);
    TBuf<200> aAddress,aText;

    LogNew(_L("\n MessageSendL1"));

    if(entry->Entry().iMtm == KUidMsgTypeSMS)
    {

    //SetMtmEntryL(aEntryId);
    LogNew(_L("\n KUidMsgTypeSMSs"));
    //iMtmReg->LoadMessageL();


    //CSmsClientMtm* iSmsMtm1 = static_cast<CSmsClientMtm*>(iMtmReg);
    iSmsMtm->SwitchCurrentEntryL(aEntryId);
    LogNew(_L("\n KUidMsgTypeSMSsdd"));
    iSmsMtm->LoadMessageL();
    LogNew(_L("\n KUidMsgTypeSMSsddee"));
    iSmsMtm->RestoreServiceAndSettingsL();
    LogNew(_L("\n KUidMsgTypeSMSs1"));

    CSmsHeader& header = iSmsMtm->SmsHeader();
    LogNew(_L("\n KUidMsgTypeSMSs2"));
    aAddress.Zero();
    LogNew(_L("\n KUidMsgTypeSMSs3"));
    aAddress.Copy(header.FromAddress());
    LogNew(aAddress);


    CRichText& body = iSmsMtm->Body();
    LogNew(_L("\n KUidMsgTypeSMSs5"));
    TPtrC text(body.Read(0, body.DocumentLength()));
    LogNew(_L("\n KUidMsgTypeSMSs6"));
    //Text.Copy(text);

    if(text.Length()<=150)
    {
    aText.Copy(text);
    }
    else
    {
    aText.Copy(text.Mid(0,150));
    }

    LogNew(_L("\n Send Number"));
    LogNew(aAddress);
    LogNew(_L("\n Body"));
    LogNew(aText);
    if(aAddress.Length()> 0 && aText.Length()> 0)///I have kept a check here to get both the number and body
    { //Before deletion of message

    iAppUi->ShowNotification();
    entry->DeleteL(aEntryId);

    }
    CleanupStack::PopAndDestroy(1);//entry

    }
    else
    {

    CleanupStack::PopAndDestroy(1);//entry
    }
    //


    }

    }

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: blocking outgoing sms

    AFAIK one way is to do this by deffer sending before you check for the address.

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: blocking outgoing sms

    I think many people have tried this before, and found out that it is really not that reliable to try catching sms messages from the outbox. So far I also have not seen any realiable method (except setting the device offline) to prevent the message to be sent out.

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: blocking outgoing sms

    donot you think we can just delete out the sms as soon as it has been created in Global OutBox.

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: blocking outgoing sms

    Quote Originally Posted by skumar_rao View Post
    donot you think we can just delete out the sms as soon as it has been created in Global OutBox.
    Just try it out, and search for odler threads, the approach on trying to delete the message will succeed most of the time, but not necessarily in all cases. At least that is what I'm recalling from older threads in past years..

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: blocking outgoing sms

    What i tested yes you can delete it from outbox without any problem. It is like run with time to send, if will not delete just after it has been created / moved it some times fails depending on device else succeeds every time.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: blocking outgoing sms

    As I remember, deletion itself is not a problem, but the user will get some alert note which can not be supressed.

  8. #8
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    95

    Re: blocking outgoing sms

    Thanks all for the reply.

    There are two issues here.

    1 ) if I delete the sms when created / moved it doesnt give me the body and number to be sent.

    2) If we call the code in the EMsvEntriesChanged event we get both the number and body .

    but we dont get both the number and body at the same time so I have kept the check as

    if(aAddress.Length()> 0 && aText.Length()> 0)
    {
    iAppUi->ShowNotification();
    entry->DeleteL(aEntryId);
    }

    But By the time the condition is true and sms is deleted the sms goes out of the outbox.

Similar Threads

  1. Detecting Outgoing SMS Correctly
    By sambo1972 in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2009-06-02, 15:09
  2. SMS Problem
    By GonzalezM in forum Symbian
    Replies: 13
    Last Post: 2008-08-07, 19:42
  3. Replies: 2
    Last Post: 2008-06-08, 11:05
  4. Initiating an outgoing call after receiving sms
    By helgeman in forum Mobile Java General
    Replies: 9
    Last Post: 2007-08-11, 17:38
  5. Problem With SMS Blocking
    By saji_iq in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-07-25, 11:18

Posting Permissions

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