views:

52

answers:

1

I have been using this code to display IMAP4 messages:

void DisplayMessageL( const TMsvId &aId )
        {
        // 1. construct the client MTM
        TMsvEntry indexEntry;
        TMsvId serviceId;
        User::LeaveIfError( iMsvSession->GetEntry(aId, serviceId, indexEntry));
        CBaseMtm* mtm = iClientReg->NewMtmL(indexEntry.iMtm);
        CleanupStack::PushL(mtm);

        // 2. construct the user interface MTM
        CBaseMtmUi* uiMtm = iUiReg->NewMtmUiL(*mtm);
        CleanupStack::PushL(uiMtm);

        // 3. display the message
        uiMtm->BaseMtm().SwitchCurrentEntryL(indexEntry.Id());
        CMsvOperationWait* waiter=CMsvOperationWait::NewLC();
        waiter->Start(); //we use synchronous waiter
        CMsvOperation* op = uiMtm->OpenL(waiter->iStatus);
        CleanupStack::PushL(op);
        CActiveScheduler::Start();

        // 4. cleanup for example even members
        CleanupStack::PopAndDestroy(4); // op,waiter, mtm, uimtm
        }

However, in case when user attempts to download a remote message (i.e. one of the emails previously not retrieved from the mail server), and then cancels the request, my code remains blocked, and it never receives information that the action was canceled.

My question is:

  • what is the workaround for the above, so the application is not stuck?
  • can anyone provide a working example for asynchronous call for opening remote messages which do not panic and crash the application?

Asynchronous calls for POP3, SMTP and local IMAP4 messages work perfectly, but remote IMAP4 messages create this issue.

I am testing these examples for S60 5th edition.

Thank you all in advance.

A: 

First of all, I would retry removing CMsvOperationWait and deal with the open request asynchronously - i.e. have an active object waiting for the CMsvOperation to complete.

CMsvOperationWait is nothing more than a convenience to make an asynch operation appear synchronous and my suspicion is that this is culprit - in the case of download->show message, there are two asynch operations chained.

KevinD
I have tried asynchronous calls, and I also tried to keep CActiveScheduler::Start() in the loop in this example, but the real issue is that canceling the download operation does not seem to generate any event.
Bojan Milankovic