Problem with making changes in sms message :
Login to reply to this topic.
Fri, 2006-04-28 12:36
Anonymous
Forum posts: 2037
i'm trying to make some changes in message entry in following code.
but doesnt work.

void CSMSEngine::UpdateMessageL(TMsvId aFolder,TInt aMsgId,const TDes& aSender,const TDes& aDescrip,const TDes& aMsgTxt)
   {
   //Switch Folder
   iSmsMtm->SwitchCurrentEntryL( aFolder );
   //Selection
   TMsvSelectionOrdering selection;
   selection.SetShowInvisibleEntries(ETrue);
   //parent entry
   CMsvEntry* parentEntry = CMsvEntry::NewL( iSmsMtm->Session(),aFolder, selection );
   CleanupStack::PushL(parentEntry);
   // Remember to delete this entry after no longer needed!
   // Only intrested in messages. Filter out service etries.
   CMsvEntrySelection* entries = parentEntry->ChildrenWithMtmL(KUidMsgTypeSMS);
   
   if (entries->Count()>0)
   {   
      CMsvEntry* msgEntry = iSmsMtm->Session().GetEntryL( (*entries)[aMsgId] );
      CleanupStack::PushL(msgEntry);
            
      iSmsMtm->SwitchCurrentEntryL(msgEntry->EntryId());
      iSmsMtm->LoadMessageL();
      
      TMsvEntry tEntry = msgEntry->Entry();          
      tEntry.SetInPreparation(EFalse);
      tEntry.iDate.HomeTime();      
      tEntry.iDetails.Set(aSender);
      tEntry.iDescription.Set(aDescrip);
      tEntry.iDetails.Set(aMsgTxt);
      tEntry.SetUnread(ETrue);
      tEntry.SetVisible(EFalse);
      
      CMsvOperationWait *theWaiter = CMsvOperationWait::NewLC(CActive::EPriorityHigh);            
      CMsvOperation *theOp = msgEntry->ChangeL(tEntry,theWaiter->iStatus);
      CleanupStack::PushL(theOp);
      theWaiter->Start();
      
//      CActiveScheduler::Start(); // here i get error (Program Closed. MSGS 259)
                           // if i dont call this then project compiles
                           // but entry isnt changed/updated.      
         
      User::LeaveIfError(theWaiter->iStatus.Int());
      CleanupStack::PopAndDestroy(2); //  theWaiter, theOp       
      
      iSmsMtm->SaveMessageL();

      CleanupStack::PopAndDestroy( msgEntry ) ;   
   }

   //clean up
   entries->Reset();
   DELETE_AND_NULLZ(entries);
   CleanupStack::PopAndDestroy(parentEntry);
   }

Mon, 2006-05-01 05:03
Joined: 2004-05-31
Forum posts: 51
Why are you trying to start the active scheduler?

I take it that CMsvOperationWait is an active object that you have written that is ment to wait until the asynchronous call ChangeL has completed?.  What I think you actually wanted to put in there is:

TRequestStatus status;
CMsvOperation *theOp = msgEntry->ChangeL(tEntry,theWaiter->status);
CleanupStack::PushL(theOp);
User::WaitForRequest(status);
User::LeaveIfError(status);
CleanupStack::PopAndDestroy(theOp);

B
Wed, 2006-05-03 21:27
Error (not verified)
Forum posts: 2037
thanks for reply.

above code (updating msgEntry later) works fine when i create a sms in Inbox locally using following code. But dont work when a sms arrives from some other phone.

anybody could tell me why it dont work Sad(


//Create message in Ibox
     iSmsMtm->SwitchCurrentEntryL(aFolderId);
     iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
     //iSmsMtm->AddAddresseeL(aAddress); //to address if need
   
     CMsvStore* aMessageStore = iSmsMtm->Entry().EditStoreL();
     CleanupStack::PushL(aMessageStore);
     CSmsHeader& iHeader = iSmsMtm->SmsHeader();
     iHeader.SetFromAddressL(aAddress);
     iHeader.StoreL(*aMessageStore);
     CleanupStack::PopAndDestroy(aMessageStore);
    
     CRichText& body = iSmsMtm->Body();    
     body.Reset();
     body.InsertL(0, aMessage);

     TMsvEntry entry = iSmsMtm->Entry().Entry();
     entry.SetInPreparation(EFalse);
     entry.SetVisible(ETrue);
     entry.iDate.HomeTime();
     entry.iDescription.Set(aDescription);
     entry.iDetails.Set(aAddress);
     entry.SetUnread(ETrue);

     iSmsMtm->Entry().ChangeL(entry);
     iSmsMtm->SaveMessageL();   


copyright 2003-2009 NewLC SARL