×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Nov 2005
    Posts
    131

    CSmsMessage to CMsvEntry

    Hi,

    is anyone able to help me in creating a new CMsvEntry in the native inbox, given CSmsMessage?
    First I have created a new CMsvEntry of type KUidMsgTypeSMS and serviceId KMsvGlobalInBoxIndexEntryId in the KUidMsvMessageEntry.
    Then I have edited the store by first StoreBodyTextL() the rich text corresponding to the sms body and then storing the CSmsHeader to the CMsvEntry's store by using the CSmsHeader::StoreL().

    Despite all it might look ok, I simply get an unknown SMS in the native inbox where I cannot open it: it throws Error -1.
    I would be thankful if someone could enlighten me on this issue.

    Thanks.

  2. #2
    Regular Contributor
    Join Date
    Nov 2005
    Posts
    131

    Re: CSmsMessage to CMsvEntry

    Related to this, does anyone know how the server message looks up the numbers and store the display name of the sender in order to be displayed in the native message?

  3. #3
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    416

    Re: CSmsMessage to CMsvEntry

    Hi beltry,

    please can you share the code? Is it necessary to create another active object just for saving messages? I need to store a message(CSmsMessage) in the inbox.

    Thank you.
    Last edited by elviin; 2009-03-24 at 11:36.

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

    Re: CSmsMessage to CMsvEntry

    Quote Originally Posted by beltry View Post
    Related to this, does anyone know how the server message looks up the numbers and store the display name of the sender in order to be displayed in the native message?
    May be this is a late reply but you can check this Wiki article: http://wiki.forum.nokia.com/index.php/Create_Local_SMS

    Also see this: http://wiki.forum.nokia.com/index.php/SMS_Operations
    Nokia Developer Wiki Moderation team

  5. #5
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    416

    Re: CSmsMessage to CMsvEntry

    Quote Originally Posted by kiran10182 View Post
    May be this is a late reply but you can check this Wiki article: http://wiki.forum.nokia.com/index.php/Create_Local_SMS

    Also see this: http://wiki.forum.nokia.com/index.php/SMS_Operations
    Thank you Kiran, every pointer is good. I'm still having problem with puting CSmsMessage in the inbox. Is there any specific code for CSmsMessage?

    Code:
    void CSmsSocketEngine::RunL()
        {
        if (iStatus == KErrNone)
            {
            if (iState == ESmsListening)
                {
                // allocate SMS buffer
                CSmsBuffer* buffer = CSmsBuffer::NewL();
                CleanupStack::PushL(buffer);
                
                // create new incoming message, pass ownership of the buffer!
                CSmsMessage* message = CSmsMessage::NewL(iFs, 
                                                         CSmsPDU::ESmsDeliver, 
                                                         buffer);
                CleanupStack::Pop(buffer);
                CleanupStack::PushL(message);
    
                // open socket read stream
                RSmsSocketReadStream readStream(iReadSocket);
                CleanupClosePushL(readStream);
    
                // read message
                message->InternalizeL(readStream);
                CleanupStack::PopAndDestroy(&readStream);
                
                TPtrC number = message->ToFromAddress();
                // extract the message body
                HBufC* body = HBufC::NewLC(message->Buffer().Length());
                TPtr bodyPtr(body->Des());
                message->Buffer().Extract(bodyPtr, 0, message->Buffer().Length());
    
                iObserver.MessageReceived(number, *body);
                CleanupStack::PopAndDestroy(2, message); // body, message
                
                // notify system about successful receiving
                iReadSocket.Ioctl(KIoctlReadMessageSucceeded, iStatus, 
                                  NULL, KSolSmsProv);
                iState = ESmsSystemNotyfing;
                SetActive();
                }
            else
                {
                Start();
                }
            }
        else
            {
            iObserver.HandleError(iStatus.Int());
            }
        }
    Last edited by elviin; 2009-03-24 at 13:30.

  6. #6
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    416

    Re: CSmsMessage to CMsvEntry

    I have put together a code that 1) retrieves sms from socket read stream 2) puts the message in the inbox.

    Can anyone leave a comment why the code for saving message does not work, exactly at the line with
    Code:
    iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
    This is the last line executed. There is no panic code or crash. The method execution just stops at CreateMessageL(KUidMsgTypeSMS.iUid):/


    The code serves just a test:
    Code:
    void CSmsService::RunL()
    {
        vp::Logger::WriteLogMessage( _L("CSmsService::RunL()") );
        vp::Logger::WriteLogMessage( _L("iStatus = %d"), iStatus.Int() );
        if ( iStatus == KErrNone )
        {
            if ( iState == ESmsListening )
            {
                // allocate SMS buffer
                CSmsBuffer* buffer = CSmsBuffer::NewL();
                CleanupStack::PushL( buffer );
    
                // create new incoming message, pass ownership of the buffer!
                CSmsMessage* message = CSmsMessage::NewL( iFs,
                        CSmsPDU::ESmsDeliver, buffer );
                CleanupStack::Pop( buffer );
                CleanupStack::PushL( message );
    
                // open socket read stream
                RSmsSocketReadStream readStream( iReadSocket );
                CleanupClosePushL( readStream );
    
                //////
                if( !iSession )
                {
                    vp::Logger::WriteLogMessage( _L("iSession = CMsvSession::OpenSyncL( *this )") );
                    iSession = CMsvSession::OpenSyncL( *this );
                }
                TMsvSelectionOrdering sort;
                vp::Logger::WriteLogMessage( _L("sort.SetShowInvisibleEntries(ETrue);") );
                sort.SetShowInvisibleEntries(ETrue);
                
                if( !iMtmRegistry )
                {
                    vp::Logger::WriteLogMessage( _L("iMtmRegistry = CClientMtmRegistry::NewL(*iSession)") );
                    iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
                }
    
                
                if(!iSmsMtm )
                {
                    vp::Logger::WriteLogMessage( _L("iSmsMtm = STATIC_CAST( CSmsClientMtm*,  iMtmRegistry->NewMtmL(KUidMsgTypeSMS))") );
                    //iSmsMtm = STATIC_CAST( CSmsClientMtm*,  iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
                    TRAPD(err, iSmsMtm = STATIC_CAST( CSmsClientMtm*,  iMtmRegistry->NewMtmL(KUidMsgTypeSMS)););
                    switch(err)
                    {
                    case KErrNotFound:
                        vp::Logger::WriteLogMessage( _L("returns KErrNotFound") );
                        break;
                    case KErrNoMemory:
                        vp::Logger::WriteLogMessage( _L("returns KErrNoMemory") );
                        break;
                    case KErrBadLibraryEntryPoint:
                        vp::Logger::WriteLogMessage( _L("returns KErrBadLibraryEntryPoint") );
                        break;
                    default:
                        vp::Logger::WriteLogMessage( _L("returns %d"), err); 
                    }
                }
                
                TBuf<10> aAddress(_L("Nokia"));
                vp::Logger::WriteLogMessage( _L("next: iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid)"));
                iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
               
                vp::Logger::WriteLogMessage( _L("next: iSmsMtm->SmsHeader()"));
                CSmsHeader& iHeader = iSmsMtm->SmsHeader();
                vp::Logger::WriteLogMessage( _L("next: iHeader.SetFromAddressL(aAddress)"));
                iHeader.SetFromAddressL(aAddress);
                
                /*
                CRichText& body = iSmsMtm->Body();
                body.Reset();
                body.InsertL(0, iMessage);
                
                
                TMsvEntry entry = iSmsMtm->Entry().Entry();
                entry.SetInPreparation(EFalse);
                entry.SetVisible(ETrue);
                entry.iDate.HomeTime();
                TBuf<20> aDescription(_L("Important Message"));
                entry.iDescription.Set(aDescription);
                entry.iDetails.Set(aAddress);
                entry.SetUnread(ETrue);
                
             
                iSmsMtm->Entry().ChangeL(entry);
                iSmsMtm->SaveMessageL();*/
                ///////
                
                
    
                    
                message->InternalizeL( readStream );
                CleanupStack::PopAndDestroy( &readStream );
    
                TPtrC number = message->ToFromAddress();
                vp::Logger::GlbFileLogger().WriteFormat(_L("sms: number = %S"), &number);
    
    
                // extract the message body
                HBufC* body = HBufC::NewLC( message->Buffer().Length() );
                TPtr bodyPtr( body->Des() );
                vp::Logger::WriteLogMessage( _L("next: message->Buffer().Extract(..)"));
                message->Buffer().Extract( bodyPtr, 0, message->Buffer().Length() );
                
                ////////////TEST
                vp::Logger::WriteLogMessage( _L("next: CRichText& richBody = iSmsMtm->Body()"));
                CRichText& richBody = iSmsMtm->Body();
                richBody.Reset();
                richBody.InsertL(0, bodyPtr);
                
                vp::Logger::WriteLogMessage( _L("next: TMsvEntry entry = iSmsMtm->Entry().Entry()"));
                TMsvEntry entry = iSmsMtm->Entry().Entry();
                entry.SetInPreparation(EFalse);
                entry.SetVisible(ETrue);
                entry.iDate.HomeTime();
                TBuf<20> aDescription(_L("Important Message"));
                entry.iDescription.Set(aDescription);
                entry.iDetails.Set(aAddress);
                entry.SetUnread(ETrue);
                
             
                vp::Logger::WriteLogMessage( _L("iSmsMtm->Entry().ChangeL(entry)") );
                iSmsMtm->Entry().ChangeL(entry);
                vp::Logger::WriteLogMessage( _L("iSmsMtm->SaveMessageL()") );
                iSmsMtm->SaveMessageL();
                ////////////TEST
    
                CleanupStack::PopAndDestroy( 2, message ); // body, message
    
                // notify system about successful receiving 
                iReadSocket.Ioctl( KIoctlReadMessageSucceeded, iStatus, NULL,
                KSolSmsProv );
                iState = ESmsSystemNotyfing;
                SetActive();
            }
            else if( iState == ESmsSystemNotyfing )
            {
                iReadSocket.Ioctl( KIoctlDeleteSmsMessage, iStatus, NULL, KSolSmsProv );
                SetActive();
            }
            else
            {
                Start();
            }
        }
        else
        {
        }
    }
    Last edited by elviin; 2009-03-25 at 12:59.

Similar Threads

  1. Commiting change on CMsvEntry leaves
    By dejan_medic in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2008-08-11, 18:41
  2. Commiting change on CMsvEntry using ChangeL leaves
    By dejan_medic in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-08-10, 08:37
  3. Commiting change on CMsvEntry leaves
    By dejan_medic in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-08-09, 20:46
  4. CSmsMessage init
    By Bill_Murray in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2006-11-28, 13:02

Posting Permissions

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