×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    8

    Getting Problem sending SMS second time.

    Hi All,

    Actually I am trying to implement SMS application , Which sends the text SMS, This is to be developed for 3rd addition.

    I am not sending the SMS using RSendAs.

    Problem Details :: When I send first sms it goes succesfully and when I got indication of first sms sent then I try to send the next sms and Problem comes that Second sms is created in Draft and it is not send ...
    I have marked in the code shown below where problem is comming..

    I have implemeted in this way

    void CMtmsEngine::SendMessageL(const TDesC& aAddr, const TDesC& aMsg)
    {

    TBuf<512> body;
    body.Copy(aMsg);


    TBuf<50> add;
    add.Copy(aAddr);

    CreateSMSMessageL(aAddr, aMsg);


    if ( ValidateCreatedSMS() )
    {

    SendMySMSL();
    }
    }

    MsvId CMtmsEngine::CreateSMSMessageL(const TDesC& aAddress,
    const TDesC& aMessage)
    {




    TBuf<60> Add;
    Add.Copy(aAddress);
    // Set SMS parameters
    TMsvEntry indexEntry;
    indexEntry.iDate.HomeTime();
    indexEntry.SetInPreparation(ETrue);
    // This is an SMS message
    indexEntry.iMtm = KUidMsgTypeSMS;
    indexEntry.iType = KUidMsvMessageEntry;

    //Gets the ID of the current SMS service.
    //in 3rd edition crashes here if capabilities are wrong
    indexEntry.iServiceId = iSmsMtm->ServiceId();




    // Create entry to drafts
    iSmsMtm_S->SwitchCurrentEntryL(KMsvDraftEntryId);
    //iSmsMtm->SwitchCurrentEntryL(KMsvGlobalOutBoxIndexEntryId); //test!


    // Creates a new child entry owned by the context synchronously.
    iSmsMtm_S->Entry().CreateL(indexEntry);

    // Set the MTM's active context to the new message
    iSmsId = indexEntry.Id();
    iSmsMtm_S->SwitchCurrentEntryL(iSmsId);

    // Add message body. Body is set twice because index entry keeps a copy
    // of some summary information. Index entry and full stored entry
    // must be in sync.
    CRichText& body = iSmsMtm_S->Body();
    body.Reset();
    body.InsertL(0, aMessage);
    indexEntry.iDescription.Set(aMessage);


    // Add destination address (recipient).Copy address also to the index entry
    iSmsMtm_S->AddAddresseeL(Add);
    indexEntry.iDetails.Set(Add);


    // Commit changes because index entry is only a local variable
    iSmsMtm_S->Entry().ChangeL(indexEntry);


    // Save full message data to the store
    iSmsMtm_S->SaveMessageL();


    return iSmsId;

    }

    TBool CMtmsEngine::ValidateCreatedSMS()
    {

    TMsvPartList partsToBeChecked =
    KMsvMessagePartBody | KMsvMessagePartRecipient |
    KMsvMessagePartOriginator | KMsvMessagePartDate;

    // ValidateMessage return KErrNone if message is valid.
    TMsvPartList failedParts = iSmsMtm_S->ValidateMessage(partsToBeChecked);



    if (failedParts == KMsvMessagePartNone)
    {
    return ETrue;
    }
    else
    {
    return EFalse;
    }
    }

    void CMtmsEngine::SendMySMSL()
    {

    // Changes the entry on which later actions are performed to the entry
    // with the specified TMsvId.
    iSmsMtm_S->SwitchCurrentEntryL(iSmsId);
    // Load the created message
    iSmsMtm_S->LoadMessageL();

    // Gets the current SMS service settings
    //CSmsSettings& serviceSettings = iSmsMtm->ServiceSettings();

    CSmsHeader& header = iSmsMtm_S->SmsHeader();
    CSmsSettings& serviceSettings = iSmsMtm_S->ServiceSettings();

    CSmsSettings* sendOptions = CSmsSettings::NewL();
    CleanupStack::PushL(sendOptions);
    sendOptions->CopyL(serviceSettings); // restore existing settings
    sendOptions->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2);

    // set send options
    sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately
    header.SetSmsSettingsL(*sendOptions);
    CleanupStack::PopAndDestroy(sendOptions);

    // Gets the number of service centre addresses stored in this object.
    #ifndef __SERIES60_30__
    const TInt numSCAddresses = serviceSettings.NumSCAddresses();
    #else // In 3.0
    const TInt numSCAddresses = serviceSettings.ServiceCenterCount();
    #endif

    // There should always be a service center number
    if (numSCAddresses > 0)
    {
    TInt scIndex=0;
    #ifndef __SERIES60_30__
    scIndex = serviceSettings.DefaultSC();
    // get the service center number:
    if ((scIndex < 0) || (scIndex >= numSCAddresses))
    {
    //scIndex = 0;
    // Panic(ESmsEngineInternal);
    }
    CSmsNumber* serviceCentreNumber = &(serviceSettings.SCAddress(
    serviceSettings.DefaultSC()));

    m_pAppUi->logit3(_L("\n 5: SetServiceCenterAddressL"));
    iSmsMtm_S->SmsHeader().SetServiceCenterAddressL(
    serviceCentreNumber->Address());

    #else
    scIndex = serviceSettings.DefaultServiceCenter();

    if ((scIndex < 0) || (scIndex >= numSCAddresses))
    {
    scIndex = 0; //???
    }
    //get the service center number:
    TPtrC serviceCentreNumber =
    serviceSettings.GetServiceCenter(scIndex).Address();


    iSmsMtm_S->SmsHeader().SetServiceCenterAddressL(serviceCentreNumber);
    #endif

    }
    else
    {
    #ifndef __WINS__
    // Panic if there is no service center number
    //Panic(ESmsNoServiceSenterNumberSet);
    #endif
    }

    iSmsMtm_S->SaveMessageL();

    // Index entry must be Updated
    TMsvEntry indexEntry = iSmsMtm_S->Entry().Entry();

    // Set in-preparation flag
    indexEntry.SetInPreparation(EFalse);

    // Sets the sending state
    indexEntry.SetSendingState(KMsvSendStateWaiting);

    iSmsMtm_S->Entry().ChangeL(indexEntry);


    // Time to send the message
    //****** // Problem Comming here ************************
    Cancel();
    //**********************************************************
    iEntrySelection->Reset();
    iEntrySelection->AppendL(iSmsId);

    CMsvEntry* entry = iSession->GetEntryL(KMsvDraftEntryId);

    TRAPD(err,
    entry->CopyL(iSmsMtm_S->Entry().EntryId(), iSmsMtm_S->ServiceId(), iStatus) );

    SetActive();



    }


    Thanks,

  2. #2
    Regular Contributor
    Join Date
    May 2008
    Posts
    61

    Re: Getting Problem sending SMS second time.

    Hi
    Is this sagar pawar from Sunbeam.........Pune

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    8

    Re: Getting Problem sending SMS second time.

    No. I am not that sagar.

  4. #4
    Super Contributor
    Join Date
    Jan 2008
    Location
    Bangalore, India
    Posts
    777

    Re: Getting Problem sending SMS second time.

    just close all the resourse that were using and make new request for them.
    otherwise keep in mind which object should be live...
    Regards
    $-Nitesh-$

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    8

    Re: Getting Problem sending SMS second time.

    Thanks for reply.

    Is there any problem in code implemented ?

    Can you give some more details regarding closing all the resources,Please help me I am newbie for this.

Similar Threads

  1. Problem in SMS Sending Example
    By abhijeetguptag in forum Symbian Networking & Messaging (Closed)
    Replies: 28
    Last Post: 2011-11-22, 05:31
  2. SMS sending problem
    By jini_1 in forum Mobile Java General
    Replies: 1
    Last Post: 2006-10-13, 06:54
  3. Replies: 1
    Last Post: 2006-10-07, 18:55
  4. Problem with sending SMS in Nokia 3200 from Java app
    By destroyer2003 in forum General Messaging
    Replies: 0
    Last Post: 2004-09-22, 12:12
  5. Strange SMS sending problem
    By teddy_kim2003 in forum General Messaging
    Replies: 0
    Last Post: 2004-08-24, 09:27

Posting Permissions

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