×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    9

    How to set new & unread SMS in INBOX to old & read?

    Hi,

    Currently, i have created an application that listens and processes to new incoming SMS via HandleSessionEventL(). After the message has been read, i want to set the new/unread message to old/read message. I do this via the following:

    TMsvEntry entry( iCMsvEntry->Entry() );
    entry.SetNew( EFalse ); // message is no longer new
    entry.SetUnread( EFalse ); // message is no longer unread
    iCMsvEntry->ChangeL( entry ); // commit changes


    Unfortunately, it doesn't seems to work as the message still displayed as New & Unread inside INBOX. I wonder what am i missing.

    feel free to comments.

    Nokia N95 S60 3rd FP1


    Thanks!

  2. #2
    Registered User
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043

    Re: How to set new & unread SMS in INBOX to old & read?

    hi sweepang,
    The code looks fine. It should be able to change the entry attribute but in case it is not doing I would suggest you can have a look into your application capabilities, may be they are not sufficient enough to support this API.
    Maximus
    S60 Developer
    Impossible is nothing

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    40

    Re: How to set new & unread SMS in INBOX to old & read?

    Are you sure you are applying the message properties on the correct TMsvEntry? (what gives iCMsvEntry->Entry() back?).

    It returns the "current context's index entry". What's your current context? E.g. it could also be the root index (the Inbox itself).

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

    Re: How to set new & unread SMS in INBOX to old & read?

    Also check that you handle all change events, not just the one where the message gets constructed.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    9

    Re: How to set new & unread SMS in INBOX to old & read?

    Thanks for all the reply.

    My capabilities is set to:
    CAPABILITY NetworkServices ReadUserData UserEnvironment

    Here is the detail of my codes:

    void CHttpClientEngine::HandleSessionEventL( TMsvSessionEvent aEvent,TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    switch ( aEvent )
    {
    case EMsvServerReady://aEvent == 8
    RDebug::Printf("EMsvServerReady");
    break;
    case EMsvEntriesCreated://aEvent == 0
    {
    TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );
    if ( *entryId != KMsvGlobalInBoxIndexEntryId )
    break;
    CMsvEntrySelection* newEntries =
    STATIC_CAST( CMsvEntrySelection*, aArg1 );

    //recording the TMsvId
    iNewMsgId = newEntries->At(0);
    break;
    }
    case EMsvEntriesChanged://aEvent == 1
    {
    if ( KMsvGlobalInBoxIndexEntryId ==
    *(static_cast<TMsvId*>( aArg2 )) )
    {
    CMsvEntrySelection* newEntries =
    static_cast<CMsvEntrySelection*>(aArg1);
    if( iNewMsgId == newEntries->At(0) )
    {
    CMsvEntry* iCMsvEntry = iSMSSession->GetEntryL( iNewMsgId );
    if ( ( iCMsvEntry )->Entry().iMtm == KUidMsgTypeSMS )
    {
    CMsvStore* iCMsvStore = iCMsvEntry ->ReadStoreL();
    CleanupStack::PushL(iCMsvStore);
    if (iCMsvStore->HasBodyTextL())
    {
    CRichText* iRichText = CRichText::NewL(
    CEikonEnv::Static()->SystemParaFormatLayerL(),
    CEikonEnv::Static()->SystemCharFormatLayerL());
    iRichText->Reset();
    CleanupStack::PushL(iRichText);

    // Get the SMS body text.
    iCMsvStore->RestoreBodyTextL(*iRichText);
    const TInt length = iRichText->DocumentLength();
    TBuf8<KMessageBodySize> message;

    if ( length >= KMessageBodySize )
    {
    message.Append( iRichText->Read(0,
    KMessageBodySize -1) );
    }
    else
    {
    message.Append( iRichText->Read(0, length) );
    }
    CleanupStack::PopAndDestroy(iRichText);

    TMsvEntry entry( iCMsvEntry->Entry() );
    entry.SetNew( EFalse );
    entry.SetUnread( EFalse );
    iCMsvEntry->ChangeL( entry ); // commit changes
    }


    CleanupStack::Pop(iCMsvStore);
    }
    }
    }
    break;
    }
    default:
    break;
    }

    }

    I can read the message fine, with no problem. The attribute change is done inside EMsvEntriesChanged event. please advice.

    Thanks!

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: How to set new & unread SMS in INBOX to old & read?

    How about opening message store in Edit mode and committing changes as shown below!!!
    Code:
      case EMsvEntriesChanged://aEvent == 1
      {
    ....
    ....
          if ( ( iCMsvEntry )->Entry().iMtm == KUidMsgTypeSMS )
          {
            CMsvStore* iCMsvStore = iCMsvEntry ->EditStoreL();
    	CleanupStack::PushL(iCMsvStore);
    	if (iCMsvStore->HasBodyTextL())
    	{
    	  CRichText* iRichText = CRichText::NewL(		 
                CEikonEnv::Static()->SystemParaFormatLayerL(),
    	    CEikonEnv::Static()->SystemCharFormatLayerL());
    	  iRichText->Reset();
    	  CleanupStack::PushL(iRichText);
    			    		 
    	   // Get the SMS body text.
    	   iCMsvStore->RestoreBodyTextL(*iRichText);
    	   const TInt length = iRichText->DocumentLength();
    	   TBuf8<KMessageBodySize> message;
    
    	   if ( length >= KMessageBodySize )
    	   {
    		message.Append( iRichText->Read(0, 
                      KMessageBodySize -1) );
    	   }
    	   else
    	   {
    	        message.Append( iRichText->Read(0, length) );
    	   }	    		    
               CleanupStack::PopAndDestroy(iRichText);
    			    		 
    	    TMsvEntry entry( iCMsvEntry->Entry() );
    	    entry.SetNew( EFalse );         
    	    entry.SetUnread( EFalse );     
    	    iCMsvEntry->ChangeL( entry );  // commit changes
                iCMsvStore->CommitL();
    	}
    ...
    ...
    Try it and show your results.
    Nokia Developer Wiki Moderation team

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    9

    Re: How to set new & unread SMS in INBOX to old & read?

    hi Kiran,

    Thanks for your reply. This won't work as it fails on:
    if (iCMsvStore->HasBodyTextL())

    Thanks!

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: How to set new & unread SMS in INBOX to old & read?

    Quote Originally Posted by sweepang View Post
    hi Kiran,

    Thanks for your reply. This won't work as it fails on:
    if (iCMsvStore->HasBodyTextL())

    Thanks!
    What does it complain about? Means what is the error?
    Nokia Developer Wiki Moderation team

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: How to set new & unread SMS in INBOX to old & read?

    Apply this http://wiki.forum.nokia.com/index.ph...ded_panic_code for revealing panic codes.

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    9

    Re: How to set new & unread SMS in INBOX to old & read?

    Quote Originally Posted by kiran10182 View Post
    What does it complain about? Means what is the error?
    iCMsvStore->HasBodyTextL() will gives me EFalse instead of ETrue.

    Thanks!

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Re: How to set new & unread SMS in INBOX to old & read?

    Quote Originally Posted by sweepang View Post
    iCMsvStore->HasBodyTextL() will gives me EFalse instead of ETrue.

    Thanks!
    It might be possible that it is checking "Bluetooth" message. Check it once again.
    Nokia Developer Wiki Moderation team

Similar Threads

  1. Replies: 5
    Last Post: 2009-02-20, 12:23
  2. Read SMS/ SMS Alert.
    By nirenj in forum General Messaging
    Replies: 3
    Last Post: 2009-01-14, 12:39
  3. how i get miscall list and read sms from inbox in j2me
    By cancer86pk in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-03-05, 21:15
  4. using java to read sms inbox ?
    By fekimoki in forum Mobile Java General
    Replies: 0
    Last Post: 2004-01-03, 08:16
  5. Replies: 0
    Last Post: 2003-10-02, 18:49

Posting Permissions

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