diff -r a3a1ae9acec6 -r da5135c61bad emailuis/emailui/src/FSComposerFetchLogic.cpp --- a/emailuis/emailui/src/FSComposerFetchLogic.cpp Mon Mar 15 12:39:10 2010 +0200 +++ b/emailuis/emailui/src/FSComposerFetchLogic.cpp Wed Mar 31 21:08:33 2010 +0300 @@ -16,13 +16,10 @@ */ -// #include "emailtrace.h" #include "cfsmailclient.h" #include "cfsmailcommon.h" -// #include -//#include // #include #include "FreestyleEmailUiAppui.h" @@ -35,18 +32,18 @@ // ----------------------------------------------------------------------------- // CFsComposerFetchLogic* CFsComposerFetchLogic::NewL( CFSMailClient& aClient, - TFSMailMsgId aMailBoxId, TFSMailMsgId aFolderId, TFSMailMsgId aMessageId, - MComposerFetchLogicCallback& aObserver, CFreestyleEmailUiAppUi& aAppUi ) - { + TFSMailMsgId aMailBoxId, TFSMailMsgId aFolderId, TFSMailMsgId aMessageId, + MComposerFetchLogicCallback& aObserver, CFreestyleEmailUiAppUi& aAppUi ) + { FUNC_LOG; - CFsComposerFetchLogic* self = new (ELeave) CFsComposerFetchLogic( aClient, aObserver, aAppUi ); - CleanupStack::PushL( self ); - self->ConstructL( aMailBoxId, aFolderId, aMessageId ); - CleanupStack::Pop( self ); + CFsComposerFetchLogic* self = new (ELeave) CFsComposerFetchLogic( aClient, aObserver, aAppUi ); + CleanupStack::PushL( self ); + self->ConstructL( aMailBoxId, aFolderId, aMessageId ); + CleanupStack::Pop( self ); return self; - } + } // ----------------------------------------------------------------------------- @@ -54,13 +51,13 @@ // ----------------------------------------------------------------------------- // CFsComposerFetchLogic::CFsComposerFetchLogic( CFSMailClient& aClient, - MComposerFetchLogicCallback& aObserver, CFreestyleEmailUiAppUi& aAppUi ): - iRunMode( EModeInvalid ), iState( EStateNotStarted ), iAppUi( aAppUi ), - iClient( aClient ), iObserver( aObserver ),iFetchingCancelGoingOn(EFalse),// - iFetchingStructure(EFalse), iFetchingBody(EFalse),iRequestCompleted(EFalse)// - { + MComposerFetchLogicCallback& aObserver, CFreestyleEmailUiAppUi& aAppUi ): + iRunMode( EModeInvalid ), iState( EStateNotStarted ), iAppUi( aAppUi ), + iClient( aClient ), iObserver( aObserver ),iFetchingCancelGoingOn(EFalse), + iFetchingStructure(EFalse), iFetchingBody(EFalse),iRequestCompleted(EFalse) + { FUNC_LOG; - } + } // ----------------------------------------------------------------------------- @@ -68,23 +65,21 @@ // ----------------------------------------------------------------------------- // CFsComposerFetchLogic::~CFsComposerFetchLogic() - { + { FUNC_LOG; - //CancelFetchings(); if ( iAppUi.DownloadInfoMediator() ) { iAppUi.DownloadInfoMediator()->StopObserving( this ); } - iParts.Close(); + iParts.Close(); - //delete iAsyncWaitNote; // - delete iMessage; - delete iFolder; - delete iMailBox; + delete iMessage; + delete iFolder; + delete iMailBox; - } + } // ----------------------------------------------------------------------------- @@ -92,15 +87,15 @@ // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::ConstructL( TFSMailMsgId aMailBoxId, - TFSMailMsgId aFolderId, TFSMailMsgId aMessageId ) - { + TFSMailMsgId aFolderId, TFSMailMsgId aMessageId ) + { FUNC_LOG; - iMailBox = iClient.GetMailBoxByUidL( aMailBoxId ); - iFolder = iClient.GetFolderByUidL( aMailBoxId, aFolderId ); - iMessage = iClient.GetMessageByUidL( aMailBoxId, aFolderId, aMessageId, EFSMsgDataStructure ); + iMailBox = iClient.GetMailBoxByUidL( aMailBoxId ); + iFolder = iClient.GetFolderByUidL( aMailBoxId, aFolderId ); + iMessage = iClient.GetMessageByUidL( aMailBoxId, aFolderId, aMessageId, EFSMsgDataStructure ); - } + } // ----------------------------------------------------------------------------- @@ -108,14 +103,14 @@ // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::RunReplyLogicL() - { + { FUNC_LOG; - iRunMode = EModeReply; - iState = EStateSmartReply; - iError = KErrNone; - RunStateL(); - } + iRunMode = EModeReply; + iState = EStateSmartReply; + iError = KErrNone; + RunStateL(); + } // ----------------------------------------------------------------------------- @@ -123,19 +118,19 @@ // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::RunForwardLogicL() - { + { FUNC_LOG; - iRunMode = EModeForward; - iState = EStateSmartForward; - iError = KErrNone; - if ( iAppUi.DownloadInfoMediator() ) - { - iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() ); - } - RunStateL(); + iRunMode = EModeForward; + iState = EStateSmartForward; + iError = KErrNone; + if ( iAppUi.DownloadInfoMediator() ) + { + iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() ); + } + RunStateL(); - } + } // ----------------------------------------------------------------------------- @@ -201,14 +196,14 @@ } } - + // ----------------------------------------------------------------------------- // CFsComposerFetchLogic::RequestResponseL // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart ) - { + { FUNC_LOG; // Ignore all responses when cancelling is in progress. @@ -241,156 +236,86 @@ } } - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::StepL -// ----------------------------------------------------------------------------- -// -// -/* -void CFsComposerFetchLogic::StepL() - { - FUNC_LOG; - }*/ -// - - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::IsProcessDone -// ----------------------------------------------------------------------------- -// -// -/* -TBool CFsComposerFetchLogic::IsProcessDone() const - { - FUNC_LOG; - return iFetchComplete; - }*/ -// - - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::ProcessFinished -// ----------------------------------------------------------------------------- -// -// -/* -void CFsComposerFetchLogic::ProcessFinished() - { - FUNC_LOG; - }*/ -// - - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::DialogDismissedL -// ----------------------------------------------------------------------------- -// -/*void CFsComposerFetchLogic::DialogDismissedL( TInt aButtonId )// - { - if(aButtonId == EAknSoftkeyCancel) - { - CancelFetchings(); - iError = KErrCancel; - } - FUNC_LOG; - }*/// - - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::CycleError -// ----------------------------------------------------------------------------- -// -// -/* -TInt CFsComposerFetchLogic::CycleError( TInt aError ) - { - FUNC_LOG; - return aError; - }*/ -// - - // ----------------------------------------------------------------------------- // CFsComposerFetchLogic::RunState // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::RunStateL() - { + { FUNC_LOG; - TBool doNextState = EFalse; + TBool doNextState = EFalse; - do - { - doNextState = EFalse; + do + { + doNextState = EFalse; - switch ( iState ) - { - case EStateSmartReply: - { - TBool supported = iMailBox->HasCapability( EFSMBoxCapaSmartReply ); - if ( supported ) - { - Complete(); - } - else - { - iState = EStateStructure; - doNextState = ETrue; - } - } - break; + switch ( iState ) + { + case EStateSmartReply: + { + TBool supported = iMailBox->HasCapability( EFSMBoxCapaSmartReply ); + TBool smartEdit = iMailBox->HasCapability( EFSMBoxCapaSmartEdit ); + if ( supported && !smartEdit ) + { + Complete(); + } + else + { + iState = EStateStructure; + doNextState = ETrue; + } + } + break; - case EStateSmartForward: - { - TBool supported = iMailBox->HasCapability( EFSMBoxCapaSmartForward ); - if ( supported ) - { - Complete(); - } - else - { - iState = EStateStructure; - doNextState = ETrue; - } - } - break; + case EStateSmartForward: + { + TBool supported = iMailBox->HasCapability( EFSMBoxCapaSmartForward ); + TBool smartEdit = iMailBox->HasCapability( EFSMBoxCapaSmartEdit ); + if ( supported && !smartEdit ) + { + Complete(); + } + else + { + iState = EStateStructure; + doNextState = ETrue; + } + } + break; - case EStateStructure: - { - TBool hasStructure = TFsEmailUiUtility::IsMessageStructureKnown( *iMessage ); - if ( hasStructure ) - { - iState = EStateBody; - doNextState = ETrue; - } - else - { - RArray ids; - CleanupClosePushL( ids ); - ids.AppendL( iMessage->GetMessageId() ); - TRAP( iError, iStructureRequestId = iFolder->FetchMessagesL( ids, EFSMsgDataStructure, *this ) ); - CleanupStack::PopAndDestroy( &ids ); - if ( KErrNone == iError ) - { - // fetching started successfully - iFetchingStructure = ETrue; - // show wait note - //ShowWaitNoteL(); // - } - else - { - // error occurred - Complete(); - } - } - } - break; + case EStateStructure: + { + TBool hasStructure = TFsEmailUiUtility::IsMessageStructureKnown( *iMessage ); + if ( hasStructure ) + { + iState = EStateBody; + doNextState = ETrue; + } + else + { + RArray ids; + CleanupClosePushL( ids ); + ids.AppendL( iMessage->GetMessageId() ); + TRAP( iError, iStructureRequestId = iFolder->FetchMessagesL( ids, EFSMsgDataStructure, *this ) ); + CleanupStack::PopAndDestroy( &ids ); + if ( KErrNone == iError ) + { + // fetching started successfully + iFetchingStructure = ETrue; + } + else + { + // error occurred + Complete(); + } + } + } + break; - case EStateBody: - { - CFSMailMessagePart* body = iMessage->PlainTextBodyPartL(); + case EStateBody: + { + CFSMailMessagePart* body = iMessage->PlainTextBodyPartL(); TBool fetched = EFalse; // Do we have plain text body part if ( !body ) @@ -414,14 +339,26 @@ CleanupStack::PushL( body ); if ( fetched ) { + // with Smart if ( EModeReply == iRunMode ) { Complete(); } else if ( EModeForward == iRunMode ) { - iState = EStateAttachments; - doNextState = ETrue; + TBool smartForward = iMailBox->HasCapability( EFSMBoxCapaSmartForward ); + if ( smartForward ) + { + // do not download attachments if smartforward + Complete(); + } + else + { + // if smartforward is not suppported fetch attachments + iState = EStateAttachments; + doNextState = ETrue; + } +// Smart Edit changes end } else { @@ -438,8 +375,6 @@ { // fetching started successfully iFetchingBody = ETrue; - // show wait note if not already visible - //ShowWaitNoteL(); // } else { @@ -448,107 +383,50 @@ } } CleanupStack::PopAndDestroy( body ); - } - break; - - case EStateAttachments: - { - if ( TFsEmailUiUtility::HasUnfetchedAttachmentsL( *iMessage ) ) - { - RPointerArray attachments; - CleanupResetAndDestroyClosePushL( attachments ); + } + break; + + case EStateAttachments: + { + if ( TFsEmailUiUtility::HasUnfetchedAttachmentsL( *iMessage ) ) + { + RPointerArray attachments; + CleanupResetAndDestroyClosePushL( attachments ); iMessage->AttachmentListL( attachments ); for ( TInt i=0; iGetId(); - data.iFolderId = iMessage->GetFolderId(); - data.iMessageId = iMessage->GetMessageId(); - data.iMessagePartId = attachments[i]->GetPartId(); - iParts.AppendL( data ); - iAppUi.DownloadInfoMediator()->DownloadL( data, EFalse ); - } - else - { - iError = KErrGeneral; - Complete(); - } - } - } - CleanupStack::PopAndDestroy( &attachments ); - // show wait note if not already visible - //ShowWaitNoteL(); // - } - else - { - Complete(); - } - } - break; - } - } - while ( doNextState ); - - } - - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::ShowWaitNoteL -// ----------------------------------------------------------------------------- -// -/*void CFsComposerFetchLogic::ShowWaitNoteL() // - { - FUNC_LOG; + { + if ( !TFsEmailUiUtility::IsMessagePartFullyFetched( *attachments[i] ) ) + { + if ( iAppUi.DownloadInfoMediator() ) + { + TPartData data; + data.iMailBoxId = iMailBox->GetId(); + data.iFolderId = iMessage->GetFolderId(); + data.iMessageId = iMessage->GetMessageId(); + data.iMessagePartId = attachments[i]->GetPartId(); + iParts.AppendL( data ); + iAppUi.DownloadInfoMediator()->DownloadL( data, EFalse ); + } + else + { + iError = KErrGeneral; + Complete(); + } + } + } + CleanupStack::PopAndDestroy( &attachments ); + } + else + { + Complete(); + } + } + break; + } + } + while ( doNextState ); + } - if ( !iAsyncWaitNote ) - { - iFetchComplete = EFalse; - - // - iAsyncWaitNote = new(ELeave)CAknWaitDialog( - (REINTERPRET_CAST(CEikDialog**,&iAsyncWaitNote)), ETrue); - iAsyncWaitNote->SetCallback(this); - //iError = KErrNone; - iAsyncWaitNote->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG); - - iAsyncWaitNote = CAknWaitNoteWrapper::NewL(); // - TBool result = iAsyncWaitNote->ExecuteL( R_FSE_FETCHING_WAIT_DIALOG, *this, ETrue ); - if ( !result ) - { - // dialog was canceled - iError = KErrCancel; - // stop downloads - CancelFetchings(); - }// - // - - //iObserver.FetchLogicComplete( iState, iError ); //cmail - } - - }*/ // - -// ----------------------------------------------------------------------------- -// CFsComposerFetchLogic::AskIfUserWantsToFetchAttachmentsL -// ----------------------------------------------------------------------------- -// -/* -TBool CFsComposerFetchLogic::AskIfUserWantsToFetchAttachmentsL() - { - - CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ); - dlg->PrepareLC( R_FSE_EDITOR_CONFIRM_ATTACHMENT_DOWNLOAD_DIALOG ); - CAknQueryControl* control = STATIC_CAST( CAknQueryControl*, dlg->ControlOrNull( EGeneralQuery ) ); - HBufC* prompt = StringLoader::LoadLC( R_FSE_EDITOR_CONFIRM_ATTACHMENT_DOWNLOAD ); - control->SetPromptL( *prompt ); - CleanupStack::PopAndDestroy( prompt ); - return TBool( dlg->RunLD() ); - - } -*/ // ----------------------------------------------------------------------------- // CFsComposerFetchLogic::CancelFetchings @@ -596,7 +474,6 @@ } } - // if( !iRequestCompleted ) { if ( iObserver.FetchLogicComplete( iState, KErrCancel )) @@ -609,7 +486,6 @@ } iFetchingCancelGoingOn = EFalse; - // } // ----------------------------------------------------------------------------- @@ -617,38 +493,20 @@ // ----------------------------------------------------------------------------- // void CFsComposerFetchLogic::Complete() - { + { FUNC_LOG; - // if(!iRequestCompleted) { - // - if ( iAppUi.DownloadInfoMediator() ) - { - iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() ); - } - - /*if ( iAsyncWaitNote ) // - { - iFetchComplete = ETrue; - // new note stops like this and not with IsProcessFinished method - iAsyncWaitNote->ProcessFinishedL(); - // - // observer is called in ShowWaitNoteL where showing - // wait note returns - } - else - {*/ // - // wait note not active, call observer - // + if ( iAppUi.DownloadInfoMediator() ) + { + iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() ); + } + // wait note not active, call observer iFetchingStructure = EFalse; iFetchingBody = EFalse; iRequestCompleted = ETrue; - // - iObserver.FetchLogicComplete( iState, iError ); - //} // - } + iObserver.FetchLogicComplete( iState, iError ); + } + } - } -