Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor santu.paul@gmail.com's Avatar
    Join Date
    Feb 2008
    Posts
    269
    Hi All,

    I can send sms from my application in 2nd edition. But the problem i am facing is that from an active object when i try to send a sms then the message go the outbox and wait there till i do anything in the GUI of my application. If i do something like changing the view the message is then send. Can anyone tell for what reason it is happening? How can i solve it?

    With thanks and regards,
    Santu

  2. #2
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    I'm rather sure we have nice SMS example using MTMs that works with 2nd edition, so have you had look into it, and maybe you could consider using the codes from it, at bleast it should be working strait away..

  3. #3
    Registered User andzab's Avatar
    Join Date
    Apr 2008
    Location
    Italy
    Posts
    7
    this is working fine both 2nd + 3rd

    Code:
    /*==========================Creo SMS============================PASSO 1================*/
    TBool CSmsEngine::CreateDestSMSL( const TDesC& aBody )
    {
      if( LoadDestNFromIni() ) {
          CreateDraftSMSL( iDestNum, aBody );
          return TRUE ;
      }
      /*---numero non valido per vari motivi---*/
      return FALSE ;
    }
    
    void CSmsEngine::CreateDraftSMSL(const TDesC& aAddress, const TDesC& aBody)
    {
      // Set attributes on index entry
      TMsvEntry indexEntry;
    
      indexEntry.SetInPreparation(ETrue);
      indexEntry.iMtm = KUidMsgTypeSMS;
      indexEntry.iType = KUidMsvMessageEntry;
      indexEntry.iServiceId = iSmsMtm->ServiceId();
      indexEntry.iDate.HomeTime();
      //---Create entry from this index entry----
      iSmsMtm->SwitchCurrentEntryL(KMsvDraftEntryId);
      iSmsMtm->Entry().CreateL(indexEntry);
      // Set the MTM's active context to the new message
      iSmsId = indexEntry.Id();
      iSmsMtm->SwitchCurrentEntryL(iSmsId);
      /*-------predispongo corpo---------------*/
      CRichText& body= iSmsMtm->Body();
      body.Reset();
      /*-------testo corpo messaggio-----------*/
      body.InsertL(0, aBody);
      indexEntry.iDescription.Set( aBody );
      /*-------numero destinatario-------------*/
      iSmsMtm->AddAddresseeL(aAddress);
      indexEntry.iDetails.Set(aAddress);
      //-------Update index entry---------------
      iSmsMtm->Entry().ChangeL(indexEntry);
      //-------Update store entry---------------
      iSmsMtm->SaveMessageL();
    }
    
    /*-------------------------------Controllo Validazione-----------------PASSO 2-------------*/
    TBool CSmsEngine::ValidateSMS()
    {
      TMsvPartList msgCheckParts= KMsvMessagePartBody | KMsvMessagePartRecipient |
                                  KMsvMessagePartOriginator |KMsvMessagePartDate;
      TMsvPartList msgFailParts= iSmsMtm->ValidateMessage(msgCheckParts);
      return msgFailParts==KMsvMessagePartNone;
    }
    
    /*-------------------------------Invio Immediato-----------------------PASSO 3-------------*/
    void CSmsEngine::SendSMSL()
    {
      //---------Set context to the SMS message-------------------------
      iSmsMtm->SwitchCurrentEntryL(iSmsId);
      //---------Load the message---------------------------------------
      iSmsMtm->LoadMessageL();
      //---------Set the SMS service centre address---------------------
      CSmsSettings& serviceSettings= iSmsMtm->ServiceSettings();
    #ifndef EKA2
      const TInt numSCAddresses = serviceSettings.NumSCAddresses(); // 2nd
    #else // In 3.0
      const TInt numSCAddresses = serviceSettings.ServiceCenterCount(); // 3rd
    #endif
      if( numSCAddresses >0 ) {
          //CSmsNumber* serviceCentreNumber= NULL;
          TInt scIndex=0;
    #ifndef EKA2
          scIndex= serviceSettings.DefaultSC(); // 2nd
          // get the service center number:
          if((scIndex < 0) || (scIndex >= numSCAddresses)) {
             scIndex = 0;
          }
          CSmsNumber* serviceCentreNumber= &(serviceSettings.SCAddress(serviceSettings.DefaultSC()));
          iSmsMtm->SmsHeader().SetServiceCenterAddressL(serviceCentreNumber->Address());
    #else
          scIndex= serviceSettings.DefaultServiceCenter(); // 3rd
          if( (scIndex<0) || (scIndex>=numSCAddresses) ) {
              scIndex= 0; //???
          }
          //---------get the service center number--------------------------
          TPtrC serviceCentreNumber= serviceSettings.GetServiceCenter(scIndex).Address();
          // This can only be used on SMS-SUBMIT type messages. The message PDU
          // type can be checked by using the CSmsHeader::Type API.
          iSmsMtm->SmsHeader().SetServiceCenterAddressL(serviceCentreNumber);
    #endif
        }
        else {
          // report panic, programming error - there should never be a missing service number
      }
      // Save the message
      iSmsMtm->SaveMessageL();
      // Update the index entry
      TMsvEntry indexEntry = iSmsMtm->Entry().Entry();
      indexEntry.SetInPreparation(EFalse);
      indexEntry.SetSendingState(KMsvSendStateWaiting);
      iSmsMtm->Entry().ChangeL(indexEntry);
      // Now send
      Cancel(); // prepare iOp for use
      iEntrySelection->Reset();
      iEntrySelection->AppendL(iSmsId);
    #ifndef EKA2
      TBuf8<1> dummyParams;
      iOp= iSmsMtm->InvokeAsyncFunctionL(ESmsMtmCommandScheduleCopy, *iEntrySelection, dummyParams, iStatus);
    #else  
      CMsvEntry* entry= iSession->GetEntryL(KMsvDraftEntryId);
      entry->CopyL( iSmsMtm->Entry().EntryId(), iSmsMtm->ServiceId(), iStatus) ;
    #endif
      SetActive();
    }
    
    
    /*=============================Active Object=======================================*/
    void CSmsEngine::RunL()
    {
      /*----chiama indietro l'AppUi----*/
      if( iStatus.Int()==KErrNone )
          iObserver.SmsSent(KMessageSent, iStatus.Int() );  // Tutto Ok
        else
          iObserver.SmsSent(KMessageUnsent, iStatus.Int() );
    }
    
    void CSmsEngine::DoCancel()
    {
      if( iOp ) {
          iOp->Cancel();
          delete iOp;
          iOp= NULL;
      }
    }

  4. #4
    Regular Contributor santu.paul@gmail.com's Avatar
    Join Date
    Feb 2008
    Posts
    269
    Hi symbianyucca,

    I am using that example. And it is working fine. Fine in the sense if i send sms from any class rather than an active one, it works fine. I am trying like this,

    1) First i called a function of an active object from a function of an another class.

    2) From that function of the active object i called SetActive(). And so it called the Run() function as it should be.

    3) From Run() function i called an another function from where i send a sms. But there the problem is. When i send the sms it goes to the outbox and wait there until and unless i do something with the GUI of my application. But as soon as i do something on the GUI of my application it send the sms.

    So, symbianyucca can you tell me is there any reason like we can't send sms from an active object or something like that related to active object and sending sms? Waiting for reply.

    Regards,
    Santu

  5. #5
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    You should read the Active object documentation before trying to use them, you should never call RunL by yourself, it is called by the active scheduler when the request has been completed..

  6. #6
    Regular Contributor santu.paul@gmail.com's Avatar
    Join Date
    Feb 2008
    Posts
    269
    I am not calling the Run function. I know that you should not call the Run function by yourself. I told i called the SetActive() function and this SetActive function called the Run function after completion.

    Regards,
    Santu

  7. #7
    Regular Contributor santu.paul@gmail.com's Avatar
    Join Date
    Feb 2008
    Posts
    269
    Hi all,

    Still waiting for the reply. Please tell me anyone what is the problem and how to solve that.

    Regards,
    Santu

  8. #8
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    I'm rather sure that the original Nokia example did work just fine, so mayeb you could see on what they have done differently in that example.

  9. #9
    Regular Contributor santu.paul@gmail.com's Avatar
    Join Date
    Feb 2008
    Posts
    269
    Hi symbianyucca,

    That example is working fine for me also. But when i try to send sms from an active object the sms goes to the outbox and wait there.

    Regards,
    Santu

  10. #10
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    You propably should chekc what kind of errors there are reported, at least for me if I have ever gotten a SMS stuck into outbox, it is always caused by some error..

Similar Threads

  1. Sending SMS to Group using SMS MTM in 3rd Edition.
    By sagar.pune in forum Symbian C++
    Replies: 2
    Last Post: 2008-06-03, 17:48
  2. sending SMS via exe on S60 2 Edition
    By keanu77 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-05-14, 05:32
  3. Port number for sending and receiving SMS
    By pmramprasath in forum Mobile Java General
    Replies: 5
    Last Post: 2007-01-23, 08:48
  4. HELP! problem w/ sending and reading sms..
    By mauve928 in forum General Messaging
    Replies: 0
    Last Post: 2003-12-14, 19:10
  5. Error sending SMS
    By jorge_c in forum Multimodecards
    Replies: 0
    Last Post: 2003-10-07, 11:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved