×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    11

    SMS messaging app crashes after receiving second message. Plz Help!!

    My app is supposed to receive an sms and then gather up all missed calls and send them out to the address of the sender. My problem is that it will do what it is supposed to do when it receives the first message, and after that it crashes on receipt of another message.

    I am really stuck with this and have been for a few days now. Any help would be greatly appreciated...

    Here is some of the code that i think is causing the problem

    It seems that whatever i put into the SearchInboxL method inside the if statement crashes. As i said, i am really needing help with this.

    Thanks in advance
    Steve

    Code:
    void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent,
                                          TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    static TInt iNewMessageId = 0;
    
    switch ( aEvent )
    {
            // Session to server established
    case EMsvServerReady:
                {
                TMsvId serviceId( KUidMsgTypeSMS.iUid ); // SMS service id
    
                // Determine if the event was succesful.
                // ServiceProgress inserts TBuf8 value in progress.
                TBuf8<KBfrLength> progress;
    iSession->ServiceProgress( serviceId, progress );
    _LIT8( KCompare, "KErrNone" );
    
    if ( progress.Compare( KCompare ) )
    {
    //code creates an indication to the user that pops up
                    HBufC* text = StringLoader::LoadLC( R_SMS_SERVER_SESSION );
                    CAknInformationNote* informationNote =
                        new ( ELeave ) CAknInformationNote;
                    informationNote->ExecuteLD( *text );
                    CleanupStack::PopAndDestroy( text );
    
                    // Check that MtmRegistry has not already been accessed.
                    if ( !iMtmRegistry )
                        {
                        AccessMtmL();
                        }
                    }
    
                else
    {
                    HBufC* text = StringLoader::LoadLC( R_SMS_SESSION_ERROR );
                    CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote;
                    errorNote->ExecuteLD( *text );
                    CleanupStack::PopAndDestroy( text );
                    }
    
                break;
                }
    
            // A new entry has been created on the message server.
    
    
    case EMsvEntriesCreated:
    {
    if(*(static_cast<TMsvId *>(aArg2)) == KMsvGlobalInBoxIndexEntryId) {
    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection *>(aArg1);
    
    iNewMessageId = entries->At(0);
    }
    
    break;
    }
    case EMsvEntriesChanged:       
    {
    // We are interested in messages that are created in Inbox
    TMsvId* entryId = static_cast<TMsvId*>(aArg2);          // entry id from the session event
    
    if (*entryId == KMsvGlobalInBoxIndexEntryId)  // new entry has been created in Inbox folder
    {
    // We take the created entries into a selection
    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    
    TInt index = entries->Find(iNewMessageId);
    
    if(KErrNotFound == index) {
    break;
    }
    
    
    if ( MessageReplyL(entries->At(index)) )
    {
    SearchInboxL(); //check for unread messages
    MessageReceivedL(entries->At(index));//send messages to the user
    }
    
    iNewMessageId = 0 ;
    }
    
    break;
    }
    
            case EMsvCloseSession:
            case EMsvServerTerminated:
            case EMsvGeneralError:
            case EMsvServerFailedToStart:
                {
                iSmsAppUi->ServerDown( aEvent );    // close application
                break;
                }
    
            // All other events are ignored.
            default:
                break;
            }
        }
    
    //...
    
    void CSmsHandler::SearchInboxL()
        {
    
       
        CMsvEntry* serverEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
        CleanupStack::PushL( serverEntry );
    
    
    CMsvEntrySelection* unreadEntries = serverEntry->ChildrenL(); //will need to be destroyed in the destructor
    
    CleanupStack::PopAndDestroy( serverEntry ) ;
    //entry = NULL ;
    TInt nCount = unreadEntries->Count();
    
    //it seems that whatever i put inside here crashes...
    if(nCount>0)
    {
    for(TInt index = 0; index < nCount; index++)
    {
       
    TMsvId entryID = unreadEntries->At( index );       
    serverEntry = iSession->GetEntryL( entryID );       
    CleanupStack::PushL( serverEntry );
    TMsvEntry msvEntry = serverEntry->Entry();
    
    if ( msvEntry.Unread() )
    {
    iSelection->AppendL(entryID);
    //unreadEnries->AppendL(entryID);
    //iUnreadMessages++;
    
    
    }
    
    CleanupStack::PopAndDestroy( serverEntry ); // entry
       
    }
    delete unreadEntries;
    }
    
        }

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    11

    Re: SMS messaging app crashes after receiving second message. Plz Help!!

    I was doing something stupid in the messageReplyL function that was screwing it up. I had loaded a message in, was accessing the body and header of the message, but didn't need to do this as i was using find() to search through the text anyway.

Similar Threads

  1. Receiving SMS by J2ME Midlet on 3410
    By mlamb in forum Mobile Java General
    Replies: 6
    Last Post: 2009-03-24, 13:13
  2. [moved] Receiving WAP Push message
    By doctordwarf in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2008-10-01, 06:20
  3. Symbian C++ - Series 60 - How can i extract details for an SMS message?
    By periakaruppan in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2005-08-02, 10:42
  4. GDP SMS receiving on S60 ?
    By ilpor in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-09-07, 18:19
  5. Receiving SMS messages
    By Freestyler in forum Mobile Java General
    Replies: 3
    Last Post: 2003-05-22, 17:06

Posting Permissions

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