diff -r e7aa27f58ae1 -r e1b6206813b4 emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp --- a/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp Tue Feb 02 00:02:40 2010 +0200 +++ b/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp Fri Feb 19 22:37:30 2010 +0200 @@ -12,7 +12,7 @@ * Contributors: * * Description : FreestyleEmailUi message details view implementation -* Version : %version: e002sa38#46 % +* Version : %version: e003sa37#48 % * */ @@ -37,8 +37,8 @@ // // -#include "CFSMailMessage.h" -#include "CFSMailClient.h" +#include "cfsmailmessage.h" +#include "cfsmailclient.h" // #include "FSEmailBuildFlags.h" @@ -57,6 +57,7 @@ #include "fstreeplaintwolineitemdata.h" #include "fstreeplaintwolineitemvisualizer.h" #include +#include "AknWaitDialog.h" // // INTERNAL INCLUDES @@ -101,7 +102,9 @@ BaseConstructL( R_FSEMAILUI_MAIL_DETAILS_VIEW ); iFirstStartCompleted = EFalse; - + iFetchingMessageStructure = EFalse; + iAsyncProcessComplete = ETrue; + iWaitDialog = NULL; } // CFSEmailUiMsgDetailsVisualiser::DoFirstStartL() @@ -271,6 +274,24 @@ if ( iViewedMsg ) // Safety check { + // + // The code below fetches the mail structure in order to have access to all detail needed. + // IMAP - hasStructure should be always True + // POP - it is False if the message has not been read yet so the code below + // should fetch the message structure + iAsyncProcessComplete = ETrue; + TBool hasStructure = TFsEmailUiUtility::IsMessageStructureKnown( *iViewedMsg ); + if (!hasStructure) + { + iWaitDialog = new (ELeave) CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse); + iWaitDialog->SetCallback(this); + iWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG); + + iDialogNotDismissed = ETrue; + iAsyncProcessComplete = EFalse; + StartFetchingMessageStructureL(iViewedMsg); + } + // // Set title bar text to "Message/Meeting details" ChangeTitleBarTextL( ETrue ); @@ -295,9 +316,17 @@ iParentLayout->SetRect( iScreenRect ); ClearMsgDetailsModelL(); + // + // IMAP - hasStructure is True so the view can be updated. + // POP - if hasStructure is False then the message strucure is being fetched. Wait for responce that will be received in + // observer method RequestResponseL( ... ) + if ( hasStructure ) + { UpdateMsgDetailsModelL(); iTreeList->ShowListL(); } + // + } } // Touch iTreeList->SetFocusedL(ETrue); @@ -307,6 +336,9 @@ void CFSEmailUiMsgDetailsVisualiser::ChildDoDeactivate() { FUNC_LOG; + // + CancelFetching(); + // if ( !iAppUi.AppUiExitOngoing() ) { if ( iTreeList->IsFocused() ) @@ -1810,3 +1842,145 @@ aLayoutArray.AppendL( iParentLayout ); } +// +// --------------------------------------------------------------------------- +// Fetching the Message Structure. It is necessary for POP protocol in order to read recipients +// --------------------------------------------------------------------------- +// +void CFSEmailUiMsgDetailsVisualiser::StartFetchingMessageStructureL( + CFSMailMessage* aMsg) + { + FUNC_LOG; + TFSMailMsgId currentMailboxId = aMsg->GetMailBoxId(); + TFSMailMsgId currentMessageFolderId = aMsg->GetFolderId(); + CFSMailFolder* currentFolder = iAppUi.GetMailClient()->GetFolderByUidL( + currentMailboxId, currentMessageFolderId); + CleanupStack::PushL(currentFolder); + RArray messageIds; + CleanupClosePushL(messageIds); + messageIds.Append(aMsg->GetMessageId()); + // Fetch the message structure + iCurrentStructureFetchRequestId = currentFolder->FetchMessagesL(messageIds, + EFSMsgDataStructure, *this); + iFetchingMessageStructure = ETrue; + CleanupStack::PopAndDestroy(&messageIds); + CleanupStack::PopAndDestroy(currentFolder); + } +// + +// +// --------------------------------------------------------------------------- +// MFSMailRequestObserver interface implementation +// --------------------------------------------------------------------------- +// +void CFSEmailUiMsgDetailsVisualiser::RequestResponseL(TFSProgress aEvent, + TInt aRequestId) + { + FUNC_LOG; + if (aRequestId == iCurrentStructureFetchRequestId && iFetchingMessageStructure) + { + if (aEvent.iError != KErrNone || aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled) + { + iAsyncProcessComplete = ETrue; + iFetchingMessageStructure = EFalse; + } + else if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete) + { + iAsyncProcessComplete = ETrue; + iFetchingMessageStructure = EFalse; + + // get message again, there might be new information + if (iViewedMsg) + { + TFSMailMsgId mailboxId = iViewedMsg->GetMailBoxId(); + TFSMailMsgId folderId = iViewedMsg->GetFolderId(); + TFSMailMsgId messageId = iViewedMsg->GetMessageId(); + UpdateMessagePtrL(mailboxId, folderId, messageId); + } + } + } + // + if (iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed) + { + iWaitDialog->ProcessFinishedL(); // deletes the dialog + } + // + + if (iViewedMsg) //safety check + { + UpdateMsgDetailsModelL(); + iTreeList->ShowListL(); + iTreeList->SetFocusedL(ETrue); + } + } +// + +// +// --------------------------------------------------------------------------- +// Update our message pointer and saves its status +// --------------------------------------------------------------------------- +// +void CFSEmailUiMsgDetailsVisualiser::UpdateMessagePtrL( + TFSMailMsgId aNewMailboxId, TFSMailMsgId aNewFolderId, + TFSMailMsgId aNewMessageId) + { + FUNC_LOG; + if (iViewedMsg) + { + + delete iViewedMsg; + iViewedMsg = NULL; + } + + // it should contain all data now (including recipients) + iViewedMsg = iAppUi.GetMailClient()->GetMessageByUidL(aNewMailboxId, + aNewFolderId, aNewMessageId, EFSMsgDataEnvelope); + + if (iViewedMsg) + { + // Save read status + iViewedMsg->SaveMessageL(); + } + } +// + +// +// --------------------------------------------------------------------------- +// Cancel fetching of the message structure +// --------------------------------------------------------------------------- +// +void CFSEmailUiMsgDetailsVisualiser::CancelFetching() + { + FUNC_LOG; + + if (iFetchingMessageStructure) + { + TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentStructureFetchRequestId ) ); + iFetchingMessageStructure = EFalse; + } + iAsyncProcessComplete = ETrue; + if (iWaitDialog && iDialogNotDismissed) + { + TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); // deletes the dialog + iWaitDialog = NULL; + } + // + } +// + +// +// --------------------------------------------------------------------------- +// MProgressDialogCallback interface implementation +// --------------------------------------------------------------------------- +// +void CFSEmailUiMsgDetailsVisualiser::DialogDismissedL( TInt aButtonId) + { + FUNC_LOG; + iDialogNotDismissed = EFalse; + if( aButtonId == EAknSoftkeyCancel ) + { + CancelFetching(); + } + + } +//