×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    5

    Client exit when new sms(general sms, not related with APP) comes,

    void CSmsSimEngine::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)
    {


    CMsvEntry* parentEntry = NULL;
    TInt err = KErrNone;


    switch (aEvent)
    {

    case EMsvServerReady: //case added by arun
    {


    if(iMtmRegistry == NULL)
    {

    TRAP(err,iMtmRegistry = CClientMtmRegistry::NewL(*iSession));


    }
    }
    break;
    case EMsvEntriesCreated:
    {



    // notifies changes in the Inbox
    if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)
    {
    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    if(entries->Count()<=0)
    {
    iNewMessageId =-1;
    return;
    }
    iNewMessageId = entries->At(0);
    }
    }
    break;

    case EMsvEntriesChanged:
    {

    //reading the SMS here into a rich text object , after its entry has been finally created
    if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)
    {
    CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    if(entries->Count()<=0)
    {
    iNewMessageId =-1;
    return;
    }



    if (iNewMessageId == entries->At(0))
    {




    CMsvEntry* entry = NULL;
    TRAP(err,entry = iSession->GetEntryL(entries->At(0)));


    //aded patch
    //the sms can get deleted after this event because of
    //secure functionalities.
    if(err != KErrNone)
    {

    delete entry;
    iNewMessageId = -1;




    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));





    return;

    }

    TMsvEntry msvEntry1 = entry->Entry();

    if (msvEntry1.iMtm != KUidMsgTypeSMS)
    {


    delete entry;
    iNewMessageId = -1;



    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));






    return;

    }

    if(iMtmRegistry == NULL)
    {



    TRAP(err,iMtmRegistry = CClientMtmRegistry::NewL(*iSession));


    }

    //eanupStack::PushL(entry);
    if(iMtm == NULL)
    {



    TRAP(err,iMtm = iMtmRegistry->NewMtmL(entry->Entry().iMtm));



    }
    // Check if our mtm is different from the mtm set to our entry
    else if (entry->Entry().iMtm != (iMtm->Entry()).Entry().iMtm)
    {


    //delete iMtm;
    //iMtm = NULL;

    //iMtm = iMtmRegistry->NewMtmL(entry->Entry().iMtm); commented by arun


    delete entry;
    iNewMessageId = -1;

    return;

    }


    TRAP(err,iMtm->SetCurrentEntryL(entry));




    if(err != KErrNone)
    {

    delete entry;
    iNewMessageId = -1;





    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));




    return;

    }

    TRAP(err,iMtm->LoadMessageL());


    if(err != KErrNone)
    {

    delete entry;
    iNewMessageId = -1;





    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));




    return;

    }

    TMsvEntry msvEntry = iMtm->Entry().Entry();

    CRichText& body = iMtm->Body();

    //TBuf<128> iExit1;
    //iExit1.Copy(body.Read(0));
    //iExit1.Delete(iExit1.Length()-1,1);

    //CEikonEnv::Static ()->AlertWin(iExit1);

    TPtrC text(body.Read(0, KSimChangeSms.iTypeLength));

    if (text.Compare(KSimChangeSms) == 0) // message is targeted to us
    {


    parentEntry = CMsvEntry::NewL(*iSession, msvEntry.Parent(), TMsvSelectionOrdering());

    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);



    iAppUi.iSmsValue = -1;
    iAppUi.Show = 0;

    #ifndef __UIQ__
    if(iAppUi.iWaitDialog != NULL)
    {

    iAppUi.iWaitDialog->ProcessFinishedL();
    iAppUi.iWaitDialog = NULL;
    }

    //CAknInformationNote* note = new(ELeave) CAknInformationNote;
    //note->ExecuteLD(_L("Validated"));
    #else
    //iAppUi.iSmsValue = 2;
    iAppUi.ShowView();
    #endif

    iAppUi.ConnectToServerForChangingNumber();

    delete entry;
    iNewMessageId =-1;



    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));




    break;

    }

    TPtrC text1(body.Read(0, KContactChangeSms.iTypeLength));

    if (text1.Compare(KContactChangeSms) == 0) // message is targeted to us
    {



    iAppUi.iSmsValue = -1;

    parentEntry = CMsvEntry::NewL(*iSession, msvEntry.Parent(), TMsvSelectionOrdering());

    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);



    if(iAppUi.iContactsHandler->iContactsUpload == 0)
    {
    iAppUi.iSynchronize = 0;
    iAppUi.UpdateContacts(0);
    }
    delete entry;
    iNewMessageId =-1;



    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));






    break;

    }

    TPtrC text2(body.Read(0, KRegistrationSms.iTypeLength));

    if (text2.Compare(KRegistrationSms) == 0) // message is targeted to us
    {


    iAppUi.iSmsValue = -1;

    parentEntry = CMsvEntry::NewL(*iSession, msvEntry.Parent(), TMsvSelectionOrdering());

    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);

    iAppUi.iRegBuffer.Copy(body.Read(0));
    iAppUi.iRegBuffer.Delete(iAppUi.iRegBuffer.Length()-1,1);



    delete entry;
    iNewMessageId =-1;



    if(!iAppUi.RegFileExists())
    iAppUi.ProcessConfigSms();


    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));




    break;


    }

    TPtrC text3(body.Read(0, KExitSms.iTypeLength));

    if (text3.Compare(KExitSms) == 0) // message is targeted to us
    {


    iAppUi.iSmsValue = -1;

    parentEntry = CMsvEntry::NewL(*iSession, msvEntry.Parent(), TMsvSelectionOrdering());

    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL)
    parentEntry->DeleteL(msvEntry.Id());

    CleanupStack::PopAndDestroy(parentEntry);


    iExit.Copy(body.Read(0));
    iExit.Delete(0,KExitSms().Length()-1);
    iExit.Delete(iExit.Length()-1,1);

    delete entry;
    iNewMessageId =-1;




    iAppUi.ProcessSmsForExit(iExit);



    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));




    break;


    }
    //the sms is not what we are looking to

    delete temp;
    //After delete entry App exits
    delete entry;


    //delete iMtm;
    iMtm = NULL;


    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));



    }

    }
    else
    {


    iMtm = NULL;
    delete iMtmRegistry;
    iMtmRegistry = NULL;

    delete iSession;
    iNewMessageId = -1;
    TRAPD(err,iSession = CMsvSession::OpenAsyncL(*this));





    }
    }
    break;
    default:
    // do nothing
    break;
    }


    }

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Client exit when new sms(general sms, not related with APP) comes,

    Get panic code from application.
    http://wiki.forum.nokia.com/index.ph...ded_panic_code

    Also put some logs to know where is the problem.


    Note: pasting to much long file/code is somewhat difficult to read. You can put code in <code cpp> </code> tag.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,699

    Re: Client exit when new sms(general sms, not related with APP) comes,

    Nice post. You may consider adding [CODE ] and [/CODE ] tags (without the spaces), which result in preserved formatting (http://discussion.forum.nokia.com/fo...71&postcount=8).
    Check the panic code: http://wiki.forum.nokia.com/index.ph...ded_panic_code
    And try debugging your code in the emulator - you can emulate receipt of messages via a simple way: send a new message with the built-in Messaging application (you can set anything when asked for SMSC), then copy/move the file (message0.sms usually) appearing in epoc32\winscw\c\smsout to smsin. The file will disappear, and arrive to the inbox - also triggering your HandleSessionEventL method, which you can debug now.

Similar Threads

  1. Run PyS60 App from a SMS
    By aymanshamma in forum Symbian
    Replies: 7
    Last Post: 2014-06-12, 17:14
  2. Replies: 2
    Last Post: 2007-11-10, 13:19
  3. after moving an sms from inbox to MyFolder my app crashes......
    By bharats in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-05-05, 13:51
  4. Where can I find the SMS java library related with the SMS API?
    By peterli007 in forum General Messaging
    Replies: 1
    Last Post: 2002-07-15, 09:22

Posting Permissions

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