emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
branchRCL_3
changeset 60 d620048b4810
parent 52 efd4f1afd43e
child 61 dcf0eedfc1a3
equal deleted inserted replaced
52:efd4f1afd43e 60:d620048b4810
    61 
    61 
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    63 #include "FSDelayedLoader.h"
    63 #include "FSDelayedLoader.h"
    64 #include "FreestyleMessageHeaderURL.h"
    64 #include "FreestyleMessageHeaderURL.h"
    65 #include "FreestyleEmailUiAknStatusIndicator.h"
    65 #include "FreestyleEmailUiAknStatusIndicator.h"
    66 #include <akntoolbar.h>
    66 
    67 
    67 #include <eiksoftkeyimage.h>
    68 CFsEmailUiHtmlViewerView* CFsEmailUiHtmlViewerView::NewL( 
    68 
       
    69 CFsEmailUiHtmlViewerView* CFsEmailUiHtmlViewerView::NewL(
    69     CAlfEnv& aEnv,
    70     CAlfEnv& aEnv,
    70     CFreestyleEmailUiAppUi& aAppUi, 
    71     CFreestyleEmailUiAppUi& aAppUi,
    71     CAlfControlGroup& aControlGroup )
    72     CAlfControlGroup& aControlGroup )
    72     {
    73     {
    73     FUNC_LOG;
    74     FUNC_LOG;
    74     CFsEmailUiHtmlViewerView* self = new ( ELeave ) CFsEmailUiHtmlViewerView( aEnv, aAppUi, aControlGroup );
    75     CFsEmailUiHtmlViewerView* self = new ( ELeave ) CFsEmailUiHtmlViewerView( aEnv, aAppUi, aControlGroup );
    75     CleanupStack::PushL( self );
    76     CleanupStack::PushL( self );
    77     CleanupStack::Pop( self );
    78     CleanupStack::Pop( self );
    78     return self;
    79     return self;
    79     }
    80     }
    80 
    81 
    81 CFsEmailUiHtmlViewerView::CFsEmailUiHtmlViewerView( CAlfEnv& aEnv,
    82 CFsEmailUiHtmlViewerView::CFsEmailUiHtmlViewerView( CAlfEnv& aEnv,
    82         CFreestyleEmailUiAppUi& aAppUi, 
    83         CFreestyleEmailUiAppUi& aAppUi,
    83         CAlfControlGroup& aControlGroup )
    84         CAlfControlGroup& aControlGroup )
    84         : CFsEmailUiViewBase( aControlGroup, aAppUi ),
    85         : CFsEmailUiViewBase( aControlGroup, aAppUi ),
    85         iEnv( aEnv )
    86         iEnv( aEnv )
    86     {
    87     {
    87     FUNC_LOG;
    88     FUNC_LOG;
    94     if ( iAppUi.DownloadInfoMediator() && iMessage )
    95     if ( iAppUi.DownloadInfoMediator() && iMessage )
    95         {
    96         {
    96         iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
    97         iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
    97         }
    98         }
    98 
    99 
    99     // <cmail>
       
   100     if ( iContainer )
   100     if ( iContainer )
   101         {
   101         {
   102         iContainer->PrepareForExit();
   102         iContainer->PrepareForExit();
   103         }
   103         }
   104 
   104 
   105     delete iNewMailTempAddress;
   105     delete iNewMailTempAddress;
   106     // </cmail>
       
   107     if ( iContainer )
   106     if ( iContainer )
   108         {
   107         {
   109         iContainer->CancelFetch();
   108         iContainer->CancelFetch();
   110         }
   109         }
   111     delete iContainer;
   110     delete iContainer;
   114     delete iOpenMessages;
   113     delete iOpenMessages;
   115     iOpenMessages = NULL;
   114     iOpenMessages = NULL;
   116     delete iEmbeddedMessages;
   115     delete iEmbeddedMessages;
   117     iEmbeddedMessages = NULL;
   116     iEmbeddedMessages = NULL;
   118     iMessage = NULL;
   117     iMessage = NULL;
   119     
   118 
   120     delete iMailBox; 
   119     delete iMailBox;
   121     iMailBox = NULL;
   120     iMailBox = NULL;
   122     delete iAsyncCallback;
   121     delete iAsyncCallback;
   123     }
   122     }
   124 
   123 
   125 void CFsEmailUiHtmlViewerView::ConstructL()
   124 void CFsEmailUiHtmlViewerView::ConstructL()
   126     {
   125     {
   127     FUNC_LOG;
   126     FUNC_LOG;
   128     BaseConstructL( R_FSEMAILUI_HTML_VIEW );
   127     BaseConstructL( R_FSEMAILUI_HTML_VIEW_FULLSCREEN );
   129     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
   128     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
   130     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
   129     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
   131     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
   130     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
   132     iNextOrPrevMessageSelected = EFalse; 
   131     iNextOrPrevMessageSelected = EFalse;
   133     iForwardingMessage = EFalse;
   132     iForwardingMessage = EFalse;
   134     iMessageIsDeleted = EFalse;
   133     iMessageIsDeleted = EFalse;
   135     }
   134     }
   136 
   135 
   137 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   221                             }
   220                             }
   222                         CSchemeHandler* handler = CSchemeHandler::NewL( *url );
   221                         CSchemeHandler* handler = CSchemeHandler::NewL( *url );
   223                         CleanupStack::PushL( handler );
   222                         CleanupStack::PushL( handler );
   224                         handler->HandleUrlStandaloneL();
   223                         handler->HandleUrlStandaloneL();
   225                         CleanupStack::PopAndDestroy( handler );
   224                         CleanupStack::PopAndDestroy( handler );
   226                         CleanupStack::PopAndDestroy( url );                                     
   225                         CleanupStack::PopAndDestroy( url );
   227                         }
   226                         }
   228                     break;
   227                     break;
   229                     case TBrCtlDefs::EElementNone:
   228                     case TBrCtlDefs::EElementNone:
   230                     default:
   229                     default:
   231                         break;
   230                         break;
   316                     {
   315                     {
   317                     TAttachmentListActivationData params;
   316                     TAttachmentListActivationData params;
   318                     params.iMailBoxId = iMessage->GetMailBoxId();
   317                     params.iMailBoxId = iMessage->GetMailBoxId();
   319                     params.iFolderId = iMessage->GetFolderId();
   318                     params.iFolderId = iMessage->GetFolderId();
   320                     params.iMessageId = iMessage->GetMessageId();
   319                     params.iMessageId = iMessage->GetMessageId();
   321                     
   320 
   322                     // use package buffer to pass the params
   321                     // use package buffer to pass the params
   323                     TPckgBuf<TAttachmentListActivationData> buf( params );
   322                     TPckgBuf<TAttachmentListActivationData> buf( params );
   324                     TUid emptyCustomMessageId = { 0 };
   323                     TUid emptyCustomMessageId = { 0 };
   325                     iAppUi.EnterFsEmailViewL( AttachmentMngrViewId, emptyCustomMessageId, buf );
   324                     iAppUi.EnterFsEmailViewL( AttachmentMngrViewId, emptyCustomMessageId, buf );
   326                     }
   325                     }
   362                  }
   361                  }
   363              case EFsEmailUiCmdCompose:
   362              case EFsEmailUiCmdCompose:
   364                  {
   363                  {
   365                  if ( iMessage )
   364                  if ( iMessage )
   366                      {
   365                      {
   367                      
   366 
   368                      if ( iActivationData.iEmbeddedMessageMode )
   367                      if ( iActivationData.iEmbeddedMessageMode )
   369                          {
   368                          {
   370                          iCreateNewMsgFromEmbeddedMsg = ETrue;
   369                          iCreateNewMsgFromEmbeddedMsg = ETrue;
   371                          }
   370                          }
   372                      
   371 
   373                      HBufC* mailAddress=iMessage->GetSender()->GetEmailAddress().AllocLC();
   372                      HBufC* mailAddress=iMessage->GetSender()->GetEmailAddress().AllocLC();
   374                      delete iNewMailTempAddress;
   373                      delete iNewMailTempAddress;
   375                      iNewMailTempAddress = NULL;
   374                      iNewMailTempAddress = NULL;
   376                      iNewMailTempAddress = CFSMailAddress::NewL();
   375                      iNewMailTempAddress = CFSMailAddress::NewL();
   377                      iNewMailTempAddress->SetEmailAddress( *mailAddress );
   376                      iNewMailTempAddress->SetEmailAddress( *mailAddress );
   390                 */
   389                 */
   391                 }
   390                 }
   392             break;
   391             break;
   393             }
   392             }
   394         }
   393         }
   395     TIMESTAMP( "Html viewer selected operation done" );    
   394     TIMESTAMP( "Html viewer selected operation done" );
   396     }
   395     }
   397 
   396 
   398 // ---------------------------------------------------------------------------
   397 // ---------------------------------------------------------------------------
   399 // Changes the MSK command depending on the focused element.
   398 // Changes the MSK command depending on the focused element.
   400 // ---------------------------------------------------------------------------
   399 // ---------------------------------------------------------------------------
   475     {
   474     {
   476     FUNC_LOG;
   475     FUNC_LOG;
   477 
   476 
   478     TBool msgBodyStructurePresent ( EFalse );
   477     TBool msgBodyStructurePresent ( EFalse );
   479     TBool msgBodyContentPresent ( EFalse );
   478     TBool msgBodyContentPresent ( EFalse );
   480     
   479 
   481     if( aCustomMessageId != KHtmlViewerReturnToPrevious)
   480     if( aCustomMessageId != KHtmlViewerReturnToPrevious)
   482      {
   481      {
   483      ViewEntered( aPrevViewId );
   482      ViewEntered( aPrevViewId );
   484      }
   483      }
   485 
   484 
   486     if ( iMrObserverToInform && 
   485     if ( iMrObserverToInform &&
   487          aCustomMessageId == KStartViewerReturnToPreviousMsg )
   486          aCustomMessageId == KStartViewerReturnToPreviousMsg )
   488         {
   487         {
   489         // If returning from view launched by MRUI, complete the ongoing
   488         // If returning from view launched by MRUI, complete the ongoing
   490         // async process.
   489         // async process.
   491         // Exception is the move message operation as it is not done through
   490         // Exception is the move message operation as it is not done through
   513         pckgData.Copy( aCustomMessage );
   512         pckgData.Copy( aCustomMessage );
   514         iActivationData = pckgData();
   513         iActivationData = pckgData();
   515         }
   514         }
   516 
   515 
   517     CleanupClosePushL( iActivationData.iFile );
   516     CleanupClosePushL( iActivationData.iFile );
   518     
   517 
   519     if ( !iMessage && iContainer )
   518     if ( !iMessage && iContainer )
   520         {
   519         {
   521         iContainer->ResetContent();
   520         iContainer->ResetContent();
   522         iAppUi.RemoveFromStack( iContainer );
   521         iAppUi.RemoveFromStack( iContainer );
   523         iContainer->CancelFetch();
   522         iContainer->CancelFetch();
   524         iContainer->ClearCacheAndLoadEmptyContent();
   523         iContainer->ClearCacheAndLoadEmptyContent();
   525         }
   524         }
   526     
   525 
   527     if ( !iContainer )
   526     if ( !iContainer )
   528         {
   527         {
   529         iContainer = CFsEmailUiHtmlViewerContainer::NewL( iAppUi, *this );
   528         iContainer = CFsEmailUiHtmlViewerContainer::NewL( iAppUi, *this );
   530         }
   529         }
   531    
   530 
   532     // Check whether this activation is actually for a meeting request
   531     // Check whether this activation is actually for a meeting request
   533     TBool openedInMrViewer( EFalse );    
   532     TBool openedInMrViewer( EFalse );
   534     if ( THtmlViewerActivationData::EMailMessage == iActivationData.iActivationDataType )
   533     if ( THtmlViewerActivationData::EMailMessage == iActivationData.iActivationDataType )
   535         {
   534         {
   536         openedInMrViewer = IsOpenedInMRViewerL();
   535         openedInMrViewer = IsOpenedInMRViewerL();
   537         }
   536         }
   538 
   537 
   539     if ( openedInMrViewer )
   538     if ( openedInMrViewer )
   540         {
   539         {
   541         // The previous contents are cleared (otherwise they are shown just
   540         // The previous contents are cleared (otherwise they are shown just
   542         // before the meeting request viewer kicks in, especially annoying 
   541         // before the meeting request viewer kicks in, especially annoying
   543         // when navigating between prev/next meeting requests by using navi
   542         // when navigating between prev/next meeting requests by using navi
   544         // decorator array buttons.
   543         // decorator array buttons.
   545         iContainer->ClearCacheAndLoadEmptyContent();
   544         iContainer->ClearCacheAndLoadEmptyContent();
   546         ClearMailViewer();
   545         ClearMailViewer();
   547         }
   546         }
   548     
   547 
   549     ShowContainerL();
   548     ShowContainerL();
   550         
   549 
   551     switch ( iActivationData.iActivationDataType )
   550     switch ( iActivationData.iActivationDataType )
   552         {
   551         {
   553         case THtmlViewerActivationData::EMailMessage:
   552         case THtmlViewerActivationData::EMailMessage:
   554             {
   553             {
   555                 
   554 
   556             if ( iMessage && iAppUi.DownloadInfoMediator() )
   555             if ( iMessage && iAppUi.DownloadInfoMediator() )
   557                 {
   556                 {
   558                 iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
   557                 iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
   559                 }
   558                 }
   560             
   559 
   561             //clean message stack which owns object iMessage
   560             //clean message stack which owns object iMessage
   562             EraseMessageStack();
   561             EraseMessageStack();
   563             iMessage = NULL;
   562             iMessage = NULL;
   564             iMessage = iAppUi.GetMailClient()->GetMessageByUidL(
   563             iMessage = iAppUi.GetMailClient()->GetMessageByUidL(
   565             iActivationData.iMailBoxId,
   564             iActivationData.iMailBoxId,
   566             iActivationData.iFolderId,
   565             iActivationData.iFolderId,
   567             iActivationData.iMessageId,
   566             iActivationData.iMessageId,
   568             EFSMsgDataEnvelope  );
   567             EFSMsgDataEnvelope  );
   569             
       
   570             UpdateToolbarL();
       
   571 
   568 
   572             if ( iMessage && iAppUi.DownloadInfoMediator() )
   569             if ( iMessage && iAppUi.DownloadInfoMediator() )
   573                 {
   570                 {
   574                 iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() );
   571                 iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() );
   575                 }
   572                 }
   576             
   573 
   577             delete iAttachmentsListModel;
   574             delete iAttachmentsListModel;
   578             iAttachmentsListModel = NULL;
   575             iAttachmentsListModel = NULL;
   579 
   576 
   580             if ( iMessage )
   577             if ( iMessage )
   581                 {
   578                 {
   584                     {
   581                     {
   585                     //take ownership of iMessage
   582                     //take ownership of iMessage
   586                     PushMessageL( iMessage, EFalse );
   583                     PushMessageL( iMessage, EFalse );
   587                     }
   584                     }
   588 
   585 
   589                 if ( openedInMrViewer )       
   586                 if ( openedInMrViewer )
   590                     {
   587                     {
       
   588                     iContainer->DisplayStatusIndicatorL();
       
   589                     iAppUi.GetMailClient()->PrepareMrDescriptionL( iActivationData.iMailBoxId,
       
   590                                                                    iActivationData.iMessageId );
       
   591 
   591                     // Setting MSK empty. This blocks unwanted MSK keypresses before MrViewer is initialized.
   592                     // Setting MSK empty. This blocks unwanted MSK keypresses before MrViewer is initialized.
   592                     ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
   593                     ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
   593                     iMrUiActive = ETrue;
   594                     iMrUiActive = ETrue;
   594                     iAppUi.MrViewerInstanceL()->ExecuteViewL( *iMessage, *this );  
   595                     iAppUi.MrViewerInstanceL()->ExecuteViewL( *iMessage, *this );
   595                     }                              
   596                     }
   596                 else
   597                 else
   597                     {
   598                     {
   598                     // Attachment list model is not created when opening mrViewer, so attachment options menu is
   599                     // Attachment list model is not created when opening mrViewer, so attachment options menu is
   599                     // not working with MR messages
   600                     // not working with MR messages
   600                     iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   601                     iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   601                     TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId );
   602                     TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId );
   602                     iAttachmentsListModel->UpdateListL( msgPartData );
   603                     iAttachmentsListModel->UpdateListL( msgPartData );
   603                     CheckMessageBodyL( *iMessage, msgBodyStructurePresent, msgBodyContentPresent );
   604                     CheckMessageBodyL( *iMessage, msgBodyStructurePresent, msgBodyContentPresent );
   604                     LoadContentFromMailMessageL( iMessage, ETrue );
   605                     LoadContentFromMailMessageL( iMessage, ETrue );
   605                     }                
   606                     }
   606                 }
   607                 }
   607             else
   608             else
   608                 {
   609                 {
   609                 User::Leave( KErrNotFound );
   610                 User::Leave( KErrNotFound );
   610                 }
   611                 }
   611             
   612 
   612             if ( aCustomMessageId != KStartViewerReturnToPreviousMsg && iMessage )
   613             if ( aCustomMessageId != KStartViewerReturnToPreviousMsg && iMessage )
   613                 {
   614                 {
   614                 delete iMailBox; iMailBox = NULL;
   615                 delete iMailBox; iMailBox = NULL;
   615                 iMailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
   616                 iMailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
   616                 
   617 
   617                 // Change active mailbox if necessary
   618                 // Change active mailbox if necessary
   618                 if ( !iMessage->GetMailBoxId().IsNullId() )
   619                 if ( !iMessage->GetMailBoxId().IsNullId() )
   619                     {
   620                     {
   620                     iAppUi.SetActiveMailboxL( iMessage->GetMailBoxId(), EFalse );
   621                     iAppUi.SetActiveMailboxL( iMessage->GetMailBoxId(), EFalse );
   621                     }
   622                     }
   627             {
   628             {
   628             if ( aCustomMessageId != KStartViewerReturnFromEmbeddedMsg && !iCreateNewMsgFromEmbeddedMsg )
   629             if ( aCustomMessageId != KStartViewerReturnFromEmbeddedMsg && !iCreateNewMsgFromEmbeddedMsg )
   629                 {
   630                 {
   630                 PushMessageL(iActivationData.iEmbeddedMessage, ETrue);
   631                 PushMessageL(iActivationData.iEmbeddedMessage, ETrue);
   631                 }
   632                 }
   632             
   633 
   633             iMessage = iOpenMessages->Head();
   634             iMessage = iOpenMessages->Head();
   634             iCreateNewMsgFromEmbeddedMsg = EFalse;
   635             iCreateNewMsgFromEmbeddedMsg = EFalse;
   635             
   636 
   636             delete iAttachmentsListModel;
   637             delete iAttachmentsListModel;
   637             iAttachmentsListModel = NULL;
   638             iAttachmentsListModel = NULL;
   638             iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   639             iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   639             
   640 
   640             if ( iOpenMessages->Head()== iOpenMessages->Last() )
   641             if ( iOpenMessages->Head()== iOpenMessages->Last() )
   641                 {
   642                 {
   642                 TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId);
   643                 TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId);
   643                 iAttachmentsListModel->UpdateListL( msgPartData );
   644                 iAttachmentsListModel->UpdateListL( msgPartData );
   644                                 
   645 
   645                 }
   646                 }
   646             else{
   647             else{
   647                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
   648                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
   648                 }                
   649                 }
   649             
   650 
   650             CheckMessageBodyL( *iOpenMessages->Head(), msgBodyStructurePresent, msgBodyContentPresent );
   651             CheckMessageBodyL( *iOpenMessages->Head(), msgBodyStructurePresent, msgBodyContentPresent );
   651             LoadContentFromMailMessageL( iOpenMessages->Head(), ETrue );
   652             LoadContentFromMailMessageL( iOpenMessages->Head(), ETrue );
   652             
   653 
   653             // update tool bar as some action menu boton should not appear in embbeded messages.
       
   654             UpdateToolbarL();
       
   655             
       
   656             }
   654             }
   657         break;
   655         break;
   658         case THtmlViewerActivationData::EFile:
   656         case THtmlViewerActivationData::EFile:
   659             {
   657             {
   660             LoadContentFromFileL( iActivationData.iFile );
   658             LoadContentFromFileL( iActivationData.iFile );
   669             {
   667             {
   670             LoadContentFromUrlL( iActivationData.iUrl );
   668             LoadContentFromUrlL( iActivationData.iUrl );
   671             }
   669             }
   672         break;
   670         break;
   673         }
   671         }
   674     
   672 
   675     CleanupStack::PopAndDestroy( &iActivationData.iFile );
   673     CleanupStack::PopAndDestroy( &iActivationData.iFile );
   676     SetMskL();
   674     SetMskL();
   677     
   675 
   678     if(iMessage)
   676     if(iMessage)
   679         {
   677         {
   680         CFSMailAddress* address = iMessage->GetSender();
   678         CFSMailAddress* address = iMessage->GetSender();
   681         if ( address )
   679         if ( address )
   682             {
   680             {
   683             HBufC* displayName = address->GetDisplayName().AllocLC();
   681             HBufC* displayName = address->GetDisplayName().AllocLC();
   684             
   682 
   685             if ( displayName->Length() )
   683             if ( displayName->Length() )
   686                 {
   684                 {
   687                 iAppUi.SetTitlePaneTextL( *displayName );
   685                 iAppUi.SetTitlePaneTextL( *displayName );
   688                 }
   686                 }
   689             else
   687             else
   693                 CleanupStack::PopAndDestroy(emailAddress);
   691                 CleanupStack::PopAndDestroy(emailAddress);
   694                 }
   692                 }
   695         CleanupStack::PopAndDestroy( displayName );
   693         CleanupStack::PopAndDestroy( displayName );
   696             }
   694             }
   697         }
   695         }
   698     
   696 
   699     if ( !openedInMrViewer && iMessage)
   697     if ( !openedInMrViewer && iMessage)
   700         {
   698         {
   701         CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   699         CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   702         TFetchedType type;
   700         TFetchedType type;
   703         if ( htmlBodyPart )
   701         if ( htmlBodyPart )
   714             {
   712             {
   715             iContainer->DisplayStatusIndicatorL();
   713             iContainer->DisplayStatusIndicatorL();
   716             StartWaitedFetchingL(EMessageStructure);
   714             StartWaitedFetchingL(EMessageStructure);
   717             iFetchingAlready = ETrue;
   715             iFetchingAlready = ETrue;
   718             }
   716             }
   719         else 
   717         else
   720             {
   718             {
   721             if ( msgBodyStructurePresent && !msgBodyContentPresent )
   719             if ( msgBodyStructurePresent && !msgBodyContentPresent )
   722                 {
   720                 {
   723                 iAsyncProcessComplete = EFalse;
   721                 iAsyncProcessComplete = EFalse;
   724                 iFetchingAlready = EFalse;
   722                 iFetchingAlready = EFalse;
   730                 }
   728                 }
   731             }
   729             }
   732        }
   730        }
   733     iNextOrPrevMessageSelected = EFalse;
   731     iNextOrPrevMessageSelected = EFalse;
   734     iForwardingMessage = EFalse;
   732     iForwardingMessage = EFalse;
   735     
   733 
   736     //update rect only if it has changed from previous time.
   734     //update rect only if it has changed from previous time.
   737     if ( iContainer->Rect() != ContainerRect()  )
   735     if ( iContainer->Rect() != ContainerRect()  )
   738         {
   736         {
   739         iContainer->SetRect( ContainerRect() );
   737         iContainer->SetRect( ContainerRect() );
   740         }
   738         }
   741     
   739 
   742     TIMESTAMP( "Html viewer opened" );    
   740     TIMESTAMP( "Html viewer opened" );
   743     }
       
   744 
       
   745 // -----------------------------------------------------------------------------
       
   746 // CFsEmailUiHtmlViewerView::OfferToolbarEventL
       
   747 // -----------------------------------------------------------------------------
       
   748 void CFsEmailUiHtmlViewerView::OfferToolbarEventL( TInt aCommand )
       
   749     {
       
   750     FUNC_LOG;
       
   751     switch (aCommand)
       
   752         {
       
   753         case EFsEmailUiTbCmdReply:
       
   754             {
       
   755             HandleCommandL(EFsEmailUiCmdActionsReply);
       
   756             break;
       
   757             }
       
   758 
       
   759         case EFsEmailUiTbCmdForward:
       
   760             {
       
   761             HandleCommandL(EFsEmailUiCmdActionsForward);
       
   762             break;
       
   763             }
       
   764         case EFsEmailUiTbCmdDelete:
       
   765             {
       
   766             iAsyncCallback->Cancel();
       
   767             iAsyncCallback->Set( TCallBack( DeleteMail, this ) );
       
   768             iAsyncCallback->SetPriority( CActive::EPriorityHigh );
       
   769             iAsyncCallback->CallBack();
       
   770             break;
       
   771             }
       
   772         case EFsEmailUiTbCmdReplyAll:
       
   773             {
       
   774             HandleCommandL(EFsEmailUiCmdActionsReplyAll);
       
   775             break;
       
   776             }
       
   777         default:
       
   778             break;
       
   779         }
       
   780     }
       
   781 
       
   782 // -----------------------------------------------------------------------------
       
   783 // CFsEmailUiHtmlViewerView::ToolbarResourceId
       
   784 // -----------------------------------------------------------------------------
       
   785 TInt CFsEmailUiHtmlViewerView::ToolbarResourceId() const
       
   786     {
       
   787     TInt resourceId( R_FREESTYLE_EMAIL_UI_TOOLBAR_HTML_MESSAGE_VIEWER_NO_REPLY_ALL );
       
   788     if (iMessage)
       
   789         {
       
   790         if (!iActivationData.iEmbeddedMessageMode && 
       
   791                 TFsEmailUiUtility::CountRecipientsSmart( iAppUi, iMessage ) > 1)
       
   792             {            
       
   793             resourceId = R_FREESTYLE_EMAIL_UI_TOOLBAR_HTML_MESSAGE_VIEWER;
       
   794             }
       
   795         }    
       
   796     return resourceId;
       
   797     }
       
   798 
       
   799 // -----------------------------------------------------------------------------
       
   800 // CFsEmailUiHtmlViewerView::GetInitiallyDimmedItemsL
       
   801 // -----------------------------------------------------------------------------
       
   802 void CFsEmailUiHtmlViewerView::GetInitiallyDimmedItemsL( const TInt aResourceId,
       
   803                 RArray<TInt>& aDimmedItems ) const
       
   804     {
       
   805     if ( R_FREESTYLE_EMAIL_UI_TOOLBAR_HTML_MESSAGE_VIEWER == aResourceId || 
       
   806          R_FREESTYLE_EMAIL_UI_TOOLBAR_HTML_MESSAGE_VIEWER_NO_REPLY_ALL == aResourceId )
       
   807         {
       
   808         if ( iActivationData.iEmbeddedMessageMode )
       
   809             {
       
   810             aDimmedItems.AppendL(EFsEmailUiTbCmdActions);
       
   811             aDimmedItems.AppendL(EFsEmailUiTbCmdDelete);
       
   812             aDimmedItems.AppendL(EFsEmailUiTbCmdReply);
       
   813             aDimmedItems.AppendL(EFsEmailUiTbCmdForward);
       
   814             aDimmedItems.AppendL(EFsEmailUiTbCmdReplyAll);
       
   815             }
       
   816         }
       
   817     }
   741     }
   818 
   742 
   819 // -----------------------------------------------------------------------------
   743 // -----------------------------------------------------------------------------
   820 // CFsEmailUiHtmlViewerView::ChildDoDeactivate()
   744 // CFsEmailUiHtmlViewerView::ChildDoDeactivate()
   821 // Deactivate the HTML view
   745 // Deactivate the HTML view
   842             {
   766             {
   843             // if app ui is exiting, a call to this function causes a KERN-EXEC 3 crash in iBrCtlInterface->ClearCache();
   767             // if app ui is exiting, a call to this function causes a KERN-EXEC 3 crash in iBrCtlInterface->ClearCache();
   844                 iContainer->ClearCacheAndLoadEmptyContent();
   768                 iContainer->ClearCacheAndLoadEmptyContent();
   845             }
   769             }
   846         }
   770         }
   847     Toolbar()->SetToolbarObserver( this );
       
   848     iMessage = NULL;
   771     iMessage = NULL;
   849     }
   772     }
   850 
   773 
   851 void CFsEmailUiHtmlViewerView::DoExitL()
   774 void CFsEmailUiHtmlViewerView::DoExitL()
   852     {
   775     {
   853     FUNC_LOG;
   776     FUNC_LOG;
   854     delete iMessage;
   777     delete iMessage;
   855     iMessage = NULL;
   778     iMessage = NULL;
   856     CancelFetchings();
   779     CancelFetchings();
   857     
   780 
   858     if ( iFlagSelectionHandler )
   781     if ( iFlagSelectionHandler )
   859         {
   782         {
   860         iFlagSelectionHandler->Cancel();
   783         iFlagSelectionHandler->Cancel();
   861         delete iFlagSelectionHandler;
   784         delete iFlagSelectionHandler;
   862         iFlagSelectionHandler = NULL;
   785         iFlagSelectionHandler = NULL;
   868 // Overriden from base class
   791 // Overriden from base class
   869 // -----------------------------------------------------------------------------
   792 // -----------------------------------------------------------------------------
   870 void CFsEmailUiHtmlViewerView::NavigateBackL()
   793 void CFsEmailUiHtmlViewerView::NavigateBackL()
   871     {
   794     {
   872     FUNC_LOG;
   795     FUNC_LOG;
   873     // clean up current message 
   796     // clean up current message
   874     if ( iMessage && iAppUi.DownloadInfoMediator() )
   797     if ( iMessage && iAppUi.DownloadInfoMediator() )
   875         {
   798         {
   876         iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
   799         iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
   877         }
   800         }
   878     if( iContainer )
   801     if( iContainer )
   884     if( tmp )
   807     if( tmp )
   885         {
   808         {
   886         delete tmp;
   809         delete tmp;
   887         tmp = NULL;
   810         tmp = NULL;
   888         }
   811         }
   889     
   812 
   890     if ( iFlagSelectionHandler )
   813     if ( iFlagSelectionHandler )
   891         {
   814         {
   892         iFlagSelectionHandler->Cancel();
   815         iFlagSelectionHandler->Cancel();
   893         delete iFlagSelectionHandler;
   816         delete iFlagSelectionHandler;
   894         iFlagSelectionHandler = NULL;
   817         iFlagSelectionHandler = NULL;
   895         }
   818         }
   896 
   819 
   897     // Return to previous message in the stack if there is still some left
   820     // Return to previous message in the stack if there is still some left
   898     if ( !iOpenMessages->IsEmpty() )
   821     if ( !iOpenMessages->IsEmpty() )
   899         {
   822         {
   900        
   823 
   901         THtmlViewerActivationData htmlData; 
   824         THtmlViewerActivationData htmlData;
   902         if ( iOpenMessages->Head()!= iOpenMessages->Last() )
   825         if ( iOpenMessages->Head()!= iOpenMessages->Last() )
   903             {
   826             {
   904             htmlData.iActivationDataType = THtmlViewerActivationData::EmbeddedEmailMessage;
   827             htmlData.iActivationDataType = THtmlViewerActivationData::EmbeddedEmailMessage;
   905             htmlData.iEmbeddedMessageMode = ETrue;
   828             htmlData.iEmbeddedMessageMode = ETrue;
   906            
   829 
   907             }
   830             }
   908         else
   831         else
   909             {
   832             {
   910             htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage;
   833             htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage;
   911             htmlData.iMailBoxId = iOpenMessages->Head()->GetMailBoxId();
   834             htmlData.iMailBoxId = iOpenMessages->Head()->GetMailBoxId();
   912             htmlData.iFolderId  = iOpenMessages->Head()->GetFolderId();
   835             htmlData.iFolderId  = iOpenMessages->Head()->GetFolderId();
   913             htmlData.iMessageId = iOpenMessages->Head()->GetMessageId();
   836             htmlData.iMessageId = iOpenMessages->Head()->GetMessageId();
   914             }
   837             }
   915         
   838 
   916         TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
   839         TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
   917         iAppUi.EnterFsEmailViewL( HtmlViewerId, KStartViewerReturnFromEmbeddedMsg, pckgData );
   840         iAppUi.EnterFsEmailViewL( HtmlViewerId, KStartViewerReturnFromEmbeddedMsg, pckgData );
   918       
   841 
   919         }
   842         }
   920     // In usual case we use the base view implementation
   843     // In usual case we use the base view implementation
   921     else
   844     else
   922         {
   845         {
   923         iMessage = NULL;
   846         iMessage = NULL;
   928             {
   851             {
   929             HideContainer();
   852             HideContainer();
   930             iContainer->ResetContent();
   853             iContainer->ResetContent();
   931             }
   854             }
   932         }
   855         }
       
   856     }
       
   857 
       
   858 // ---------------------------------------------------------------------------
       
   859 // Wrapper for implementation in view base class
       
   860 // ---------------------------------------------------------------------------
       
   861 //
       
   862 void CFsEmailUiHtmlViewerView::ChangeMskCommandL( TInt /*aLabelResourceId*/ )
       
   863     {
       
   864     CEikButtonGroupContainer* cba( Cba() );
       
   865     if ( cba )
       
   866 			{
       
   867       cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK_FULLSCREEN );
       
   868       CEikCba* eikCba( static_cast< CEikCba* >( cba->ButtonGroup() ) );
       
   869       TFileName filename;
       
   870 			TFsEmailUiUtility::GetFullIconFileNameL( filename );
       
   871 		  if (iActivationData.iEmbeddedMessageMode)
       
   872 		  	{
       
   873 	      eikCba->UpdateMSKIconL( KAknsIIDQsnIconColors,  filename,
       
   874 	          EMbmFreestyleemailuiQgn_graf_cmail_blank,
       
   875 	          EMbmFreestyleemailuiQgn_graf_cmail_blank_mask, ETrue );
       
   876 		  	}
       
   877 		  else
       
   878 		    {
       
   879 	      eikCba->UpdateMSKIconL( KAknsIIDQsnIconColors,  filename,
       
   880 	          EMbmFreestyleemailuiQgn_prop_cmail_action_delete,
       
   881 	          EMbmFreestyleemailuiQgn_prop_cmail_action_delete_mask, ETrue );
       
   882 	      }
       
   883       }
       
   884     }
       
   885 
       
   886 // ---------------------------------------------------------------------------
       
   887 // Sets status bar layout
       
   888 // ---------------------------------------------------------------------------
       
   889 //
       
   890 TBool CFsEmailUiHtmlViewerView::IsStatusPaneVisible() const
       
   891     {
       
   892     return EFalse;
   933     }
   893     }
   934 
   894 
   935 // ---------------------------------------------------------------------------
   895 // ---------------------------------------------------------------------------
   936 // Sets status bar layout
   896 // Sets status bar layout
   937 // ---------------------------------------------------------------------------
   897 // ---------------------------------------------------------------------------
   938 //
   898 //
   939 void CFsEmailUiHtmlViewerView::SetStatusBarLayout()
   899 void CFsEmailUiHtmlViewerView::SetStatusBarLayout()
   940     {
   900     {
   941     TInt res = R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT;
   901     if( StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
   942     if( Layout_Meta_Data::IsLandscapeOrientation() )
   902        {
   943         {
   903        TRAP_IGNORE( StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ) );
   944         // landscape must use different layout
   904        }
   945 		res = R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT;
       
   946         }
       
   947 
       
   948     if( StatusPane()->CurrentLayoutResId() != res )
       
   949         {
       
   950         TRAP_IGNORE(
       
   951             StatusPane()->SwitchLayoutL( res ));
       
   952         }
       
   953     }
   905     }
   954 
   906 
   955 void CFsEmailUiHtmlViewerView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
   907 void CFsEmailUiHtmlViewerView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
   956     {
   908     {
   957     FUNC_LOG;
   909     FUNC_LOG;
   958 
   910 
   959     if ( aResourceId == R_FSEMAILUI_HTMLVIEWER_MENUPANE )
   911     if ( aResourceId == R_FSEMAILUI_HTMLVIEWER_MENUPANE )
   960         {
   912         {
   961         // Pinch zoom only
   913         // Pinch zoom only
   962         aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomLevel, ETrue );
   914         aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomLevel, ETrue );
   963     
   915 
   964         if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
   916         if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
   965             {
   917             {
   966             // remove help support in pf5250
   918             // remove help support in pf5250
   967             aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
   919             aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
   968             }   
   920             }
   969         
   921 
   970         TBool toolbarExists = EFalse;
   922         const TBool toolbarExists( EFalse );
   971         if( iAppUi.CurrentFixedToolbar() )
   923 
   972             {
       
   973             toolbarExists = iAppUi.CurrentFixedToolbar()->IsVisible();
       
   974             }
       
   975         
       
   976         // Some commands are blocked when viewing embedded message object
   924         // Some commands are blocked when viewing embedded message object
   977         // or separate HTML file.
   925         // or separate HTML file.
   978         const TBool blockCmds( !iMessage || iActivationData.iEmbeddedMessageMode || toolbarExists );
   926         const TBool blockCmds( !iMessage || iActivationData.iEmbeddedMessageMode || toolbarExists );
   979         const TBool blockReplyALLCmd( toolbarExists || !iMessage || iActivationData.iEmbeddedMessageMode ||
   927         const TBool blockReplyALLCmd( toolbarExists || !iMessage || iActivationData.iEmbeddedMessageMode ||
   980                 TFsEmailUiUtility::CountRecipientsSmart( iAppUi, iMessage ) < 2 );       
   928                 TFsEmailUiUtility::CountRecipientsSmart( iAppUi, iMessage ) < 2 );
   981         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, blockCmds );
   929         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, blockCmds );
   982         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, blockReplyALLCmd );
   930         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, blockReplyALLCmd );
   983         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, blockCmds );
   931         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, blockCmds );
   984         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsDelete, blockCmds );
   932         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsDelete, blockCmds );
   985         
   933 
   986         if( iActivationData.iEmbeddedMessageMode )
   934         if( iActivationData.iEmbeddedMessageMode )
   987             {
   935             {
   988             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
   936             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
   989             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
   937             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
   990             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
   938             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
   991             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
   939             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
   992             }
   940             }
   993         
   941 
   994         TBool hideNext = !ShowNextMessageMenuInOptions();
   942         TBool hideNext = !ShowNextMessageMenuInOptions();
   995         TBool blockNextCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hideNext;
   943         TBool blockNextCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hideNext;
   996         TInt menuPos;
   944         TInt menuPos;
   997         if( aMenuPane->MenuItemExists( EFsEmailUiCmdNextMessage, menuPos ) )
   945         if( aMenuPane->MenuItemExists( EFsEmailUiCmdNextMessage, menuPos ) )
   998             {
   946             {
  1002         TBool blockPrevCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hidePrev;
   950         TBool blockPrevCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hidePrev;
  1003         if( aMenuPane->MenuItemExists( EFsEmailUiCmdPreviousMessage, menuPos ) )
   951         if( aMenuPane->MenuItemExists( EFsEmailUiCmdPreviousMessage, menuPos ) )
  1004             {
   952             {
  1005             aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, blockPrevCmd );
   953             aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, blockPrevCmd );
  1006             }
   954             }
  1007         
   955 
  1008         CFSMailFolder* currentFolder = NULL;
   956         CFSMailFolder* currentFolder = NULL;
  1009         if ( iMessage )
   957         if ( iMessage )
  1010             {
   958             {
  1011             TRAP_IGNORE( currentFolder = 
   959             TRAP_IGNORE( currentFolder =
  1012                 iAppUi.GetMailClient()->GetFolderByUidL(
   960                 iAppUi.GetMailClient()->GetFolderByUidL(
  1013                         iMessage->GetMailBoxId(), 
   961                         iMessage->GetMailBoxId(),
  1014                         iMessage->GetFolderId() ) );
   962                         iMessage->GetFolderId() ) );
  1015             }
   963             }
  1016       
   964 
  1017         if ( currentFolder &&
   965         if ( currentFolder &&
  1018              currentFolder->GetFolderType() != EFSOutbox )
   966              currentFolder->GetFolderType() != EFSOutbox )
  1019             {
   967             {
  1020             // Mark as read/unread options
   968             // Mark as read/unread options
  1021             TBool messageIsRead( iMessage->IsFlagSet( EFSMsgFlag_Read ) );
   969             TBool messageIsRead( iMessage->IsFlagSet( EFSMsgFlag_Read ) );
  1022             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageIsRead );
   970             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageIsRead );
  1023             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageIsRead );
   971             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageIsRead );
  1024             
   972 
  1025             // Move to another folder option
   973             // Move to another folder option
  1026             aMenuPane->SetItemDimmed( 
   974             aMenuPane->SetItemDimmed(
  1027                     EFsEmailUiCmdActionsMoveMessage, 
   975                     EFsEmailUiCmdActionsMoveMessage,
  1028                     !iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ) );
   976                     !iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ) );
  1029 
   977 
  1030             // Follow-up flag option
   978             // Follow-up flag option
  1031             aMenuPane->SetItemDimmed( 
   979             aMenuPane->SetItemDimmed(
  1032                     EFsEmailUiCmdActionsFlag,
   980                     EFsEmailUiCmdActionsFlag,
  1033                     !( iMailBox && TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) ) );
   981                     !( iMailBox && TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) ) );
  1034             }
   982             }
  1035         else
   983         else
  1036             {
   984             {
  1048         DynInitZoomMenuL( aMenuPane );
   996         DynInitZoomMenuL( aMenuPane );
  1049         }
   997         }
  1050     iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
   998     iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1051             CFSEmailUiShortcutBinding::EContextHtmlViewer );
   999             CFSEmailUiShortcutBinding::EContextHtmlViewer );
  1052     }
  1000     }
  1053     
  1001 
  1054 // -----------------------------------------------------------------------------
  1002 // -----------------------------------------------------------------------------
  1055 // CFsEmailUiHtmlViewerView::HandleMrCommandL
  1003 // CFsEmailUiHtmlViewerView::HandleMrCommandL
  1056 // Handle accept/decline/tentative/remove commands given for meeting request
  1004 // Handle accept/decline/tentative/remove commands given for meeting request
  1057 // message directly from list UI.
  1005 // message directly from list UI.
  1058 // -----------------------------------------------------------------------------
  1006 // -----------------------------------------------------------------------------
  1061     TFSMailMsgId aMailboxId,
  1009     TFSMailMsgId aMailboxId,
  1062     TFSMailMsgId aFolderId,
  1010     TFSMailMsgId aFolderId,
  1063     TFSMailMsgId aMessageId )
  1011     TFSMailMsgId aMessageId )
  1064     {
  1012     {
  1065     FUNC_LOG;
  1013     FUNC_LOG;
  1066     ///any init required? 
  1014     ///any init required?
  1067     UpdateMessagePtrL( aMailboxId, aFolderId, aMessageId );
  1015     UpdateMessagePtrL( aMailboxId, aFolderId, aMessageId );
  1068 
  1016 
  1069     if ( aCommandId == EFsEmailUiCmdCalRemoveFromCalendar && iMessage )
  1017     if ( aCommandId == EFsEmailUiCmdCalRemoveFromCalendar && iMessage )
  1070         {
  1018         {
  1071         iAppUi.MrViewerInstanceL()->RemoveMeetingRequestFromCalendarL(
  1019         iAppUi.MrViewerInstanceL()->RemoveMeetingRequestFromCalendarL(
  1095     }
  1043     }
  1096 
  1044 
  1097 void CFsEmailUiHtmlViewerView::HandleStatusPaneSizeChange()
  1045 void CFsEmailUiHtmlViewerView::HandleStatusPaneSizeChange()
  1098     {
  1046     {
  1099     CFsEmailUiViewBase::HandleStatusPaneSizeChange();
  1047     CFsEmailUiViewBase::HandleStatusPaneSizeChange();
  1100 	
  1048 
  1101 	HandleViewRectChange();
  1049 	HandleViewRectChange();
  1102     }
  1050     }
  1103 
  1051 
  1104 void CFsEmailUiHtmlViewerView::HandleViewRectChange()
  1052 void CFsEmailUiHtmlViewerView::HandleViewRectChange()
  1105     {
  1053     {
  1106     CFsEmailUiViewBase::HandleViewRectChange();
  1054     CFsEmailUiViewBase::HandleViewRectChange();
  1107      
  1055 
  1108      if ( iContainer )
  1056      if ( iContainer )
  1109          {
  1057          {
  1110          iContainer->SetRect( ContainerRect() );
  1058          iContainer->SetRect( ContainerRect() );
  1111          }
  1059          }
  1112     }
  1060     }
  1113 
  1061 
  1114 void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
  1062 void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
  1115     {
  1063     {
  1116     FUNC_LOG;
  1064     FUNC_LOG;
  1117     
  1065 
  1118     if ( aType == EScreenLayoutChanged )
  1066     if ( aType == EScreenLayoutChanged )
  1119         {
  1067         {
  1120         SetStatusBarLayout();
  1068         SetStatusBarLayout();
  1121         }
  1069         }
  1122     
  1070 
  1123     if ( iContainer )
  1071     if ( iContainer )
  1124         {
  1072         {
  1125         iContainer->SetRect( ContainerRect() );
  1073         iContainer->SetRect( ContainerRect() );
  1126         iContainer->HandleResourceChange( aType );
  1074         iContainer->HandleResourceChange( aType );
  1127         }
  1075         }
  1128     }
  1076     }
  1129 
  1077 
  1130 TRect  CFsEmailUiHtmlViewerView::ContainerRect() const
  1078 TRect CFsEmailUiHtmlViewerView::ContainerRect() const
  1131     {
  1079     {
  1132     TRect rect = ClientRect();
  1080     TRect rect( ClientRect() );
  1133     
  1081     return rect;
  1134     CAknToolbar* toolbar = iAppUi.CurrentFixedToolbar();
       
  1135     if( toolbar && toolbar->IsVisible() && Layout_Meta_Data::IsLandscapeOrientation() )
       
  1136         {
       
  1137         TPoint pos = toolbar->PositionRelativeToScreen();
       
  1138         
       
  1139         // In some LS status pane layouts the toolbar will be shown on top of the client area
       
  1140         if( pos.iX > 0 )
       
  1141             {
       
  1142             rect.iBr.iX = pos.iX;
       
  1143             }
       
  1144         }
       
  1145     return rect; 
       
  1146     }
  1082     }
  1147 
  1083 
  1148 void CFsEmailUiHtmlViewerView::LoadContentFromFileL( const TDesC& aFileName )
  1084 void CFsEmailUiHtmlViewerView::LoadContentFromFileL( const TDesC& aFileName )
  1149     {
  1085     {
  1150     FUNC_LOG;
  1086     FUNC_LOG;
  1209         return;
  1145         return;
  1210         }
  1146         }
  1211 
  1147 
  1212     TInt reallyDelete( ETrue );
  1148     TInt reallyDelete( ETrue );
  1213 
  1149 
  1214     if ( iAppUi.GetCRHandler()->WarnBeforeDelete() && 
  1150     if ( iAppUi.GetCRHandler()->WarnBeforeDelete() &&
  1215          !aSilentDelete )
  1151          !aSilentDelete )
  1216         {
  1152         {
  1217         reallyDelete = TFsEmailUiUtility::ShowConfirmationQueryL(
  1153         reallyDelete = TFsEmailUiUtility::ShowConfirmationQueryL(
  1218                            R_FREESTYLE_EMAIL_UI_DELETE_MESSAGE_CONFIRMATION );
  1154                            R_FREESTYLE_EMAIL_UI_DELETE_MESSAGE_CONFIRMATION );
  1219         }
  1155         }
  1226         if ( iContainer )
  1162         if ( iContainer )
  1227             {
  1163             {
  1228             HideContainer();
  1164             HideContainer();
  1229             iContainer->ResetContent();
  1165             iContainer->ResetContent();
  1230             }
  1166             }
  1231         
  1167 
  1232         RArray<TFSMailMsgId> msgIds;
  1168         RArray<TFSMailMsgId> msgIds;
  1233         CleanupClosePushL( msgIds );
  1169         CleanupClosePushL( msgIds );
  1234             
  1170 
  1235         msgIds.Append( currentMsgId );
  1171         msgIds.Append( currentMsgId );
  1236         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1172         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1237         TFSMailMsgId folderId = iMessage->GetFolderId();        
  1173         TFSMailMsgId folderId = iMessage->GetFolderId();
  1238  
  1174 
  1239         //Get the id and check if there is a previous message available 
  1175         //Get the id and check if there is a previous message available
  1240         TFSMailMsgId prevMsgId;
  1176         TFSMailMsgId prevMsgId;
  1241         TFSMailMsgId prevMsgFolderId;  
  1177         TFSMailMsgId prevMsgFolderId;
  1242         
  1178 
  1243         //Get the previous message if it exists
  1179         //Get the previous message if it exists
  1244         TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId, 
  1180         TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId,
  1245                                                    prevMsgId, 
  1181                                                    prevMsgId,
  1246                                                    prevMsgFolderId );
  1182                                                    prevMsgFolderId );
  1247         
  1183 
  1248         //Delete the message
  1184         //Delete the message
  1249         iLastDeletedMessageID = iMessage->GetMessageId(); 
  1185         iLastDeletedMessageID = iMessage->GetMessageId();
  1250         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1186         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1251         CleanupStack::PopAndDestroy( &msgIds );
  1187         CleanupStack::PopAndDestroy( &msgIds );
  1252 
  1188 
  1253         // Notify appui of deleted mail item
  1189         // Notify appui of deleted mail item
  1254         SendEventToAppUiL( TFSEventMailDeletedFromViewer ); 
  1190         SendEventToAppUiL( TFSEventMailDeletedFromViewer );
  1255         
  1191 
  1256        
  1192 
  1257         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1193         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1258             {   
  1194             {
  1259             //Open the previous message or navigate back to list viewer
  1195             //Open the previous message or navigate back to list viewer
  1260             if ( available )
  1196             if ( available )
  1261                 {
  1197                 {
  1262 				iMessageIsDeleted = ETrue;
  1198 				iMessageIsDeleted = ETrue;
  1263                 TRAPD( err, iAppUi.MoveToPreviousMsgAfterDeleteL( prevMsgId ) );
  1199                 TRAPD( err, iAppUi.MoveToPreviousMsgAfterDeleteL( prevMsgId ) );
  1264                 iMessageIsDeleted = EFalse;
  1200                 iMessageIsDeleted = EFalse;
  1265                 
  1201 
  1266                 User::LeaveIfError( err );
  1202                 User::LeaveIfError( err );
  1267                 }   
  1203                 }
  1268             else
  1204             else
  1269                 {
  1205                 {
  1270                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1206                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1271                 NavigateBackL();
  1207                 NavigateBackL();
  1272                 }
  1208                 }
  1287     {
  1223     {
  1288     FUNC_LOG;
  1224     FUNC_LOG;
  1289     if ( /*iFirstStartCompleted &&*/ iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  1225     if ( /*iFirstStartCompleted &&*/ iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  1290                                      (aEvent == TFSEventMailDeleted || aEvent == TFSEventMailDeletedFromViewer) && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  1226                                      (aEvent == TFSEventMailDeleted || aEvent == TFSEventMailDeletedFromViewer) && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  1291         {
  1227         {
  1292         TFSMailMsgId curMsgId = iMessage->GetMessageId();       
  1228         TFSMailMsgId curMsgId = iMessage->GetMessageId();
  1293         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  1229         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  1294         TBool cont = ETrue;
  1230         TBool cont = ETrue;
  1295         for ( TInt i = 0 ; i < removedEntries->Count() && cont; i++ )
  1231         for ( TInt i = 0 ; i < removedEntries->Count() && cont; i++ )
  1296             {
  1232             {
  1297             if ( ( curMsgId == ( *removedEntries )[i] ) &&
  1233             if ( ( curMsgId == ( *removedEntries )[i] ) &&
  1298                     (iDeletedMessageFromMrui != curMsgId) )
  1234                     (iDeletedMessageFromMrui != curMsgId) )
  1299                 {                
  1235                 {
  1300                 cont = EFalse;
  1236                 cont = EFalse;
  1301                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1237                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1302                 if( aEvent == TFSEventMailDeleted  && !iMessageIsDeleted )
  1238                 if( aEvent == TFSEventMailDeleted  && !iMessageIsDeleted )
  1303                     {   //Delete event came from server; close the viewer.
  1239                     {   //Delete event came from server; close the viewer.
  1304                 	HandleCommandL( EAknSoftkeyBack );
  1240                 	HandleCommandL( EAknSoftkeyBack );
  1305                 	// The message we are viewing was deleted => stop here
  1241                 	// The message we are viewing was deleted => stop here
  1306                 	return;
  1242                 	return;
  1307                     }
  1243                     }
  1308                 }            
  1244                 }
  1309             } 
  1245             }
  1310         }
  1246         }
  1311      
  1247 
  1312     if ( iContainer && iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() )
  1248     if ( iContainer && iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() )
  1313         {
  1249         {
  1314         if ( aEvent == TFSEventNewMail || 
  1250         if ( aEvent == TFSEventNewMail ||
  1315              aEvent == TFSEventMailDeleted || 
  1251              aEvent == TFSEventMailDeleted ||
  1316              aEvent == TFSEventMailChanged )
  1252              aEvent == TFSEventMailChanged )
  1317             {
  1253             {
  1318             iContainer->MailListModelUpdatedL();
  1254             iContainer->MailListModelUpdatedL();
  1319             }
  1255             }
  1320 
  1256 
  1321         // DSW fix for FAMZ-82YJQ2
  1257         // DSW fix for FAMZ-82YJQ2
  1322         // Dismiss the download status dialog after sync has been finished or cancelled
  1258         // Dismiss the download status dialog after sync has been finished or cancelled
  1323         
  1259 
  1324         if ( aEvent == TFSEventMailboxSyncStateChanged )
  1260         if ( aEvent == TFSEventMailboxSyncStateChanged )
  1325             {
  1261             {
  1326             TSSMailSyncState* newSyncState = static_cast<TSSMailSyncState*>( aParam1 );
  1262             TSSMailSyncState* newSyncState = static_cast<TSSMailSyncState*>( aParam1 );
  1327             if ( newSyncState && ( *newSyncState == FinishedSuccessfully || 
  1263             if ( newSyncState && ( *newSyncState == FinishedSuccessfully ||
  1328                                    *newSyncState == SyncCancelled || 
  1264                                    *newSyncState == SyncCancelled ||
  1329                                    *newSyncState == Idle || 
  1265                                    *newSyncState == Idle ||
  1330                                    *newSyncState == SyncError ))
  1266                                    *newSyncState == SyncError ))
  1331                 {
  1267                 {
  1332                 iContainer->HideDownloadStatus();
  1268                 iContainer->HideDownloadStatus();
  1333                 }
  1269                 }
  1334             }
  1270             }
  1335         }
  1271         }
  1336     }
  1272     }
  1337 
  1273 
  1338 void CFsEmailUiHtmlViewerView::DynInitZoomMenuL( CEikMenuPane* aMenuPane )
  1274 void CFsEmailUiHtmlViewerView::DynInitZoomMenuL( CEikMenuPane* aMenuPane )
  1339     {
  1275     {
  1340     FUNC_LOG; 
  1276     FUNC_LOG;
  1341     /* -- Pinch zoom only --
  1277     /* -- Pinch zoom only --
  1342     TInt zoomLevelIdx = iContainer->ZoomLevelL();
  1278     TInt zoomLevelIdx = iContainer->ZoomLevelL();
  1343 
  1279 
  1344     // Set the radio button state to match current zoom level
  1280     // Set the radio button state to match current zoom level
  1345     if ( zoomLevelIdx >= 0 && zoomLevelIdx < iContainer->MaxZoomLevel() )
  1281     if ( zoomLevelIdx >= 0 && zoomLevelIdx < iContainer->MaxZoomLevel() )
  1445             }
  1381             }
  1446         case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
  1382         case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
  1447             {
  1383             {
  1448             CopyCurrentToClipBoardL( aUrl );
  1384             CopyCurrentToClipBoardL( aUrl );
  1449             break;
  1385             break;
  1450             }                   
  1386             }
  1451         }
  1387         }
  1452     }
  1388     }
  1453 
  1389 
  1454 void CFsEmailUiHtmlViewerView::SaveEmailAsContactL(
  1390 void CFsEmailUiHtmlViewerView::SaveEmailAsContactL(
  1455     const TDesC& aEmailAddress )
  1391     const TDesC& aEmailAddress )
  1536     {
  1472     {
  1537     // this method assumes that remote lookup is available with current plugin.
  1473     // this method assumes that remote lookup is available with current plugin.
  1538     HBufC* textData = aEmailAddress.AllocLC();
  1474     HBufC* textData = aEmailAddress.AllocLC();
  1539     CFSMailBox* mailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
  1475     CFSMailBox* mailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
  1540     CleanupStack::PushL( mailBox );
  1476     CleanupStack::PushL( mailBox );
  1541   
       
  1542     //UI options Delete and Actions dimmed in Remote Lookup.
       
  1543     const TInt resourceId(ToolbarResourceId());
       
  1544     RArray<TInt> dimmedItems;
       
  1545     CleanupClosePushL(dimmedItems);
       
  1546     GetInitiallyDimmedItemsL(resourceId, dimmedItems); // get the currently dimmed buttons
       
  1547     
       
  1548     SetToolbarItemDimmed( EFsEmailUiTbCmdActions, ETrue);
       
  1549     SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, ETrue);
       
  1550         
       
  1551     HideToolbar();
       
  1552     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *mailBox, *textData );
  1477     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *mailBox, *textData );
  1553     ShowToolbar();  
       
  1554     
       
  1555     SetToolbarItemDimmed( EFsEmailUiTbCmdActions, EFalse);
       
  1556     SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, EFalse);
       
  1557    
       
  1558     for (TInt i = 0; i < dimmedItems.Count(); i++) // restore the buttons
       
  1559         {
       
  1560         SetToolbarItemDimmed(dimmedItems[i], ETrue);
       
  1561         }
       
  1562     CleanupStack::PopAndDestroy(); // dimmedItems.Close()
       
  1563     CleanupStack::PopAndDestroy( mailBox );
  1478     CleanupStack::PopAndDestroy( mailBox );
  1564     CleanupStack::PopAndDestroy( textData );
  1479     CleanupStack::PopAndDestroy( textData );
  1565     }
  1480     }
  1566 
  1481 
  1567 // -----------------------------------------------------------------------------
  1482 // -----------------------------------------------------------------------------
  1639         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
  1554         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
  1640         if ( downloadRequired && iContainer && !iContainer->AttachmentDownloadStatusVisible() )
  1555         if ( downloadRequired && iContainer && !iContainer->AttachmentDownloadStatusVisible() )
  1641             {
  1556             {
  1642             iContainer->ShowAttachmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1557             iContainer->ShowAttachmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1643             }
  1558             }
  1644         
  1559 
  1645         if ( savedCount )
  1560         if ( savedCount )
  1646             {
  1561             {
  1647             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );        
  1562             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );
  1648             }
  1563             }
  1649         }
  1564         }
  1650     }
  1565     }
  1651 
  1566 
  1652 void CFsEmailUiHtmlViewerView::SaveAllAttachmentsL()
  1567 void CFsEmailUiHtmlViewerView::SaveAllAttachmentsL()
  1690     return iActivationData.iEmbeddedMessageMode;
  1605     return iActivationData.iEmbeddedMessageMode;
  1691     }
  1606     }
  1692 
  1607 
  1693 TBool CFsEmailUiHtmlViewerView::IsEmbeddedMsgSavingAllowed()
  1608 TBool CFsEmailUiHtmlViewerView::IsEmbeddedMsgSavingAllowed()
  1694     {
  1609     {
  1695     return iMailBox->HasCapability( 
  1610     return iMailBox->HasCapability(
  1696                 EFSMboxCapaSupportsSavingOfEmbeddedMessages );
  1611                 EFSMboxCapaSupportsSavingOfEmbeddedMessages );
  1697     }
  1612     }
  1698 
  1613 
  1699 void CFsEmailUiHtmlViewerView::UpdateDownloadIndicatorL( 
  1614 void CFsEmailUiHtmlViewerView::UpdateDownloadIndicatorL(
  1700         const TPartData& aPart, 
  1615         const TPartData& aPart,
  1701         const TFSProgress& aEvent )
  1616         const TFSProgress& aEvent )
  1702     {
  1617     {
  1703     FUNC_LOG;
  1618     FUNC_LOG;
  1704     
  1619 
  1705     if ( !iMessage || !iContainer || ( aEvent.iError != KErrNone ) )
  1620     if ( !iMessage || !iContainer || ( aEvent.iError != KErrNone ) )
  1706         return;
  1621         return;
  1707     
  1622 
  1708     TAttachmentData* attachment = NULL;
  1623     TAttachmentData* attachment = NULL;
  1709     const RArray<TAttachmentData>& attachments = iAttachmentsListModel->GetModel();
  1624     const RArray<TAttachmentData>& attachments = iAttachmentsListModel->GetModel();
  1710     for ( TInt i=0; i < attachments.Count(); i++ )
  1625     for ( TInt i=0; i < attachments.Count(); i++ )
  1711         {
  1626         {
  1712         if ( attachments[i].partData == aPart )
  1627         if ( attachments[i].partData == aPart )
  1713             {
  1628             {
  1714             attachment = CONST_CAST( TAttachmentData*, &iAttachmentsListModel->GetModel()[i] );
  1629             attachment = CONST_CAST( TAttachmentData*, &iAttachmentsListModel->GetModel()[i] );
  1715             break;
  1630             break;
  1716             }
  1631             }
  1717         }
  1632         }
  1718     
  1633 
  1719     if ( attachment )
  1634     if ( attachment )
  1720         {
  1635         {
  1721         switch ( aEvent.iProgressStatus )
  1636         switch ( aEvent.iProgressStatus )
  1722             {
  1637             {
  1723             case TFSProgress::EFSStatus_Status:
  1638             case TFSProgress::EFSStatus_Status:
  1730                     {
  1645                     {
  1731                     attachment->downloadProgress = KNone;
  1646                     attachment->downloadProgress = KNone;
  1732                     }
  1647                     }
  1733                 }
  1648                 }
  1734             break;
  1649             break;
  1735             
  1650 
  1736             case TFSProgress::EFSStatus_RequestComplete:
  1651             case TFSProgress::EFSStatus_RequestComplete:
  1737                 {
  1652                 {
  1738                 attachment->downloadProgress = KComplete;
  1653                 attachment->downloadProgress = KComplete;
  1739                 }
  1654                 }
  1740             break;
  1655             break;
  1741             
  1656 
  1742             default:
  1657             default:
  1743                 break;
  1658                 break;
  1744             }
  1659             }
  1745         
  1660 
  1746         iContainer->ShowAttachmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1661         iContainer->ShowAttachmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1747         }
  1662         }
  1748     }
  1663     }
  1749 
  1664 
  1750 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1665 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1762 
  1677 
  1763 // -----------------------------------------------------------------------------
  1678 // -----------------------------------------------------------------------------
  1764 // CFsEmailUiHtmlViewerView::PushMessageL
  1679 // CFsEmailUiHtmlViewerView::PushMessageL
  1765 // Message stack handling. Ownership of message is transferred when succesful.
  1680 // Message stack handling. Ownership of message is transferred when succesful.
  1766 // -----------------------------------------------------------------------------
  1681 // -----------------------------------------------------------------------------
  1767 // 
  1682 //
  1768 void CFsEmailUiHtmlViewerView::PushMessageL( CFSMailMessage* aMessage, TBool aIsEmbedded )
  1683 void CFsEmailUiHtmlViewerView::PushMessageL( CFSMailMessage* aMessage, TBool aIsEmbedded )
  1769     {
  1684     {
  1770     if ( !iOpenMessages || !iEmbeddedMessages )
  1685     if ( !iOpenMessages || !iEmbeddedMessages )
  1771         {
  1686         {
  1772         User::Leave( KErrNotReady );
  1687         User::Leave( KErrNotReady );
  1791 
  1706 
  1792 // -----------------------------------------------------------------------------
  1707 // -----------------------------------------------------------------------------
  1793 // CFsEmailUiHtmlViewerView::PopMessage
  1708 // CFsEmailUiHtmlViewerView::PopMessage
  1794 // Message stack handling. Ownership of message is returned.
  1709 // Message stack handling. Ownership of message is returned.
  1795 // -----------------------------------------------------------------------------
  1710 // -----------------------------------------------------------------------------
  1796 // 
  1711 //
  1797 CFSMailMessage* CFsEmailUiHtmlViewerView::PopMessage()
  1712 CFSMailMessage* CFsEmailUiHtmlViewerView::PopMessage()
  1798     {
  1713     {
  1799     ASSERT( iOpenMessages && iEmbeddedMessages );
  1714     ASSERT( iOpenMessages && iEmbeddedMessages );
  1800     ASSERT( iOpenMessages->Count() == iEmbeddedMessages->Count() );
  1715     ASSERT( iOpenMessages->Count() == iEmbeddedMessages->Count() );
  1801     
  1716 
  1802     CFSMailMessage* msg = NULL;
  1717     CFSMailMessage* msg = NULL;
  1803     if ( !iOpenMessages->IsEmpty() )
  1718     if ( !iOpenMessages->IsEmpty() )
  1804         {
  1719         {
  1805         msg = iOpenMessages->Pop();
  1720         msg = iOpenMessages->Pop();
  1806         }
  1721         }
  1813 
  1728 
  1814 // -----------------------------------------------------------------------------
  1729 // -----------------------------------------------------------------------------
  1815 // CFsEmailUiHtmlViewerView::EraseMessageStack
  1730 // CFsEmailUiHtmlViewerView::EraseMessageStack
  1816 // Message stack handling. All messages in stack are deallocated
  1731 // Message stack handling. All messages in stack are deallocated
  1817 // -----------------------------------------------------------------------------
  1732 // -----------------------------------------------------------------------------
  1818 // 
  1733 //
  1819 void CFsEmailUiHtmlViewerView::EraseMessageStack()
  1734 void CFsEmailUiHtmlViewerView::EraseMessageStack()
  1820     {
  1735     {
  1821     ASSERT( iOpenMessages && iEmbeddedMessages );
  1736     ASSERT( iOpenMessages && iEmbeddedMessages );
  1822     ASSERT( iOpenMessages->Count() == iEmbeddedMessages->Count() );
  1737     ASSERT( iOpenMessages->Count() == iEmbeddedMessages->Count() );
  1823 
  1738 
  1875             // Send flags, local and server
  1790             // Send flags, local and server
  1876             iMessage->ResetFlag( EFSMsgFlag_Read );
  1791             iMessage->ResetFlag( EFSMsgFlag_Read );
  1877             }
  1792             }
  1878         iMessage->SaveMessageL(); // Save read status
  1793         iMessage->SaveMessageL(); // Save read status
  1879         SendEventToAppUiL( TFSEventMailChanged );
  1794         SendEventToAppUiL( TFSEventMailChanged );
  1880     
  1795 
  1881         }
  1796         }
  1882     }
  1797     }
  1883 
  1798 
  1884 // -----------------------------------------------------------------------------
  1799 // -----------------------------------------------------------------------------
  1885 // CFsEmailUiHtmlViewerView::ShowNextMessageMenuInOptions
  1800 // CFsEmailUiHtmlViewerView::ShowNextMessageMenuInOptions
  1887 TBool CFsEmailUiHtmlViewerView::ShowNextMessageMenuInOptions() const
  1802 TBool CFsEmailUiHtmlViewerView::ShowNextMessageMenuInOptions() const
  1888     {
  1803     {
  1889     FUNC_LOG;
  1804     FUNC_LOG;
  1890     TBool available = EFalse;
  1805     TBool available = EFalse;
  1891     // Next/previous message options are inavailable in the embedded mode
  1806     // Next/previous message options are inavailable in the embedded mode
  1892     if ( iMessage && !iActivationData.iEmbeddedMessageMode )    
  1807     if ( iMessage && !iActivationData.iEmbeddedMessageMode )
  1893         {
  1808         {
  1894         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  1809         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  1895         TFSMailMsgId nextMsgId;
  1810         TFSMailMsgId nextMsgId;
  1896         TFSMailMsgId nextMsgFolderId;
  1811         TFSMailMsgId nextMsgFolderId;
  1897         available = iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId );
  1812         available = iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId );
  1918                 }
  1833                 }
  1919 
  1834 
  1920             // Stop timer and cancel fetchings before showing next message
  1835             // Stop timer and cancel fetchings before showing next message
  1921             //iFetchingAnimationTimer->Stop();
  1836             //iFetchingAnimationTimer->Stop();
  1922             CancelFetchings();
  1837             CancelFetchings();
  1923            
  1838 
  1924             // Change empty msk when moving to next
  1839             // Change empty msk when moving to next
  1925             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1840             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1926 
  1841 
  1927             iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  1842             iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  1928             // Next message is displayed in this view through doactivate, because view is re-activate by mail list
  1843             // Next message is displayed in this view through doactivate, because view is re-activate by mail list
  1957         {
  1872         {
  1958         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  1873         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  1959         TFSMailMsgId prevMsgId;
  1874         TFSMailMsgId prevMsgId;
  1960         TFSMailMsgId prevMsgFolderId;
  1875         TFSMailMsgId prevMsgFolderId;
  1961         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId ) )
  1876         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId ) )
  1962             {          
  1877             {
  1963             if (iContainer)
  1878             if (iContainer)
  1964                 {
  1879                 {
  1965                 iContainer->PrepareForMessageNavigation();
  1880                 iContainer->PrepareForMessageNavigation();
  1966                 }
  1881                 }
  1967         
  1882 
  1968             // Stop timer and cancel fetchings before showing prev message
  1883             // Stop timer and cancel fetchings before showing prev message
  1969             CancelFetchings();
  1884             CancelFetchings();
  1970            
  1885 
  1971             // Change empty msk when moving to previous
  1886             // Change empty msk when moving to previous
  1972             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1887             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1973 
  1888 
  1974             iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  1889             iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  1975             // Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  1890             // Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  2198 // for MFSMailRequestObserver callback
  2113 // for MFSMailRequestObserver callback
  2199 // -----------------------------------------------------------------------------
  2114 // -----------------------------------------------------------------------------
  2200 void CFsEmailUiHtmlViewerView::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
  2115 void CFsEmailUiHtmlViewerView::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
  2201     {
  2116     {
  2202     FUNC_LOG;
  2117     FUNC_LOG;
  2203     
  2118 
  2204     TBool reloadContent ( EFalse );
  2119     TBool reloadContent ( EFalse );
  2205     
  2120 
  2206     if ( aRequestId == iCurrentPlainTextBodyFetchRequestId && iFetchingPlainTextMessageBody )
  2121     if ( aRequestId == iCurrentPlainTextBodyFetchRequestId && iFetchingPlainTextMessageBody )
  2207         {
  2122         {
  2208         if ( aEvent.iError != KErrNone ||
  2123         if ( aEvent.iError != KErrNone ||
  2209              aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled )
  2124              aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled )
  2210             {
  2125             {
  2228                 TFSMailMsgId folderId = iMessage->GetFolderId();
  2143                 TFSMailMsgId folderId = iMessage->GetFolderId();
  2229                 TFSMailMsgId messageId = iMessage->GetMessageId();
  2144                 TFSMailMsgId messageId = iMessage->GetMessageId();
  2230                 UpdateMessagePtrL( mailboxId, folderId, messageId );
  2145                 UpdateMessagePtrL( mailboxId, folderId, messageId );
  2231                 reloadContent = ETrue;
  2146                 reloadContent = ETrue;
  2232                 }
  2147                 }
  2233                           
  2148 
  2234             }
  2149             }
  2235         }
  2150         }
  2236 
  2151 
  2237     else if ( aRequestId == iCurrentHtmlBodyFetchRequestId && iFetchingHtmlMessageBody )
  2152     else if ( aRequestId == iCurrentHtmlBodyFetchRequestId && iFetchingHtmlMessageBody )
  2238         {
  2153         {
  2243             iFetchingHtmlMessageBody = EFalse;
  2158             iFetchingHtmlMessageBody = EFalse;
  2244             }
  2159             }
  2245         else if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
  2160         else if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
  2246             {
  2161             {
  2247             iAsyncProcessComplete = ETrue;
  2162             iAsyncProcessComplete = ETrue;
  2248             iFetchingHtmlMessageBody = EFalse;           
  2163             iFetchingHtmlMessageBody = EFalse;
  2249             
  2164 
  2250             reloadContent = ETrue;
  2165             reloadContent = ETrue;
  2251             
  2166 
  2252             }
  2167             }
  2253         }
  2168         }
  2254     else if ( aRequestId == iCurrentStructureFetchRequestId && iFetchingMessageStructure )
  2169     else if ( aRequestId == iCurrentStructureFetchRequestId && iFetchingMessageStructure )
  2255         {
  2170         {
  2256         if ( aEvent.iError != KErrNone ||
  2171         if ( aEvent.iError != KErrNone ||
  2279         {
  2194         {
  2280         iContainer->HideDownloadStatus();
  2195         iContainer->HideDownloadStatus();
  2281         }
  2196         }
  2282     if ( reloadContent )
  2197     if ( reloadContent )
  2283         {
  2198         {
  2284     
  2199 
  2285         if (  iContainer )
  2200         if (  iContainer )
  2286             {
  2201             {
  2287             iContainer->ResetContent();                
  2202             iContainer->ResetContent();
  2288             if( iMessage )
  2203             if( iMessage )
  2289                 {
  2204                 {
  2290                 LoadContentFromMailMessageL( iMessage , EFalse);  
  2205                 LoadContentFromMailMessageL( iMessage , EFalse);
  2291                 SetMskL();
  2206                 SetMskL();
  2292                 }
  2207                 }
  2293             }
  2208             }
  2294         }
  2209         }
  2295             
  2210 
  2296     
  2211 
  2297     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
  2212     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
  2298         {
  2213         {
  2299         iWaitDialog->ProcessFinishedL(); // deletes the dialog
  2214         iWaitDialog->ProcessFinishedL(); // deletes the dialog
  2300         }
  2215         }
  2301 
  2216 
  2359         if ( iAppUi.DownloadInfoMediator() && messageChanged )
  2274         if ( iAppUi.DownloadInfoMediator() && messageChanged )
  2360             {
  2275             {
  2361             iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() );
  2276             iAppUi.DownloadInfoMediator()->AddObserver( this, iMessage->GetMessageId() );
  2362             }
  2277             }
  2363         }
  2278         }
  2364     
       
  2365     UpdateToolbarL();
       
  2366     }
  2279     }
  2367 
  2280 
  2368 // -----------------------------------------------------------------------------
  2281 // -----------------------------------------------------------------------------
  2369 // CFsEmailUiHtmlViewerView::CancelFetchings
  2282 // CFsEmailUiHtmlViewerView::CancelFetchings
  2370 // -----------------------------------------------------------------------------
  2283 // -----------------------------------------------------------------------------
  2385         {
  2298         {
  2386         TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentStructureFetchRequestId ) );
  2299         TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentStructureFetchRequestId ) );
  2387         iFetchingMessageStructure = EFalse;
  2300         iFetchingMessageStructure = EFalse;
  2388         }
  2301         }
  2389     iAsyncProcessComplete = ETrue;
  2302     iAsyncProcessComplete = ETrue;
  2390     
  2303 
  2391     //also cancel embedded images download in DownloadInfoMediator
  2304     //also cancel embedded images download in DownloadInfoMediator
  2392     if ( iMailBox )
  2305     if ( iMailBox )
  2393         {
  2306         {
  2394         TRAP_IGNORE( iAppUi.DownloadInfoMediator()->CancelAllDownloadsL( iMailBox->GetId() ) );    
  2307         TRAP_IGNORE( iAppUi.DownloadInfoMediator()->CancelAllDownloadsL( iMailBox->GetId() ) );
  2395         }
  2308         }
  2396     
  2309 
  2397 
  2310 
  2398     //<cmail>
  2311     //<cmail>
  2399     if(iWaitDialog && iDialogNotDismissed)
  2312     if(iWaitDialog && iDialogNotDismissed)
  2400         TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); // deletes the dialog
  2313         TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); // deletes the dialog
  2401     //</cmail>
  2314     //</cmail>
  2450     /*iWaitDialog = new(ELeave)CAknWaitDialog(
  2363     /*iWaitDialog = new(ELeave)CAknWaitDialog(
  2451                    (REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), ETrue);
  2364                    (REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), ETrue);
  2452     iWaitDialog->SetCallback(this);
  2365     iWaitDialog->SetCallback(this);
  2453     iDialogNotDismissed = ETrue;
  2366     iDialogNotDismissed = ETrue;
  2454     iWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG);
  2367     iWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG);
  2455     */ 
  2368     */
  2456     if( iMessage )
  2369     if( iMessage )
  2457         {
  2370         {
  2458         StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  2371         StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  2459         }
  2372         }
  2460       //  iFetchingAlready = ETrue;
  2373       //  iFetchingAlready = ETrue;
  2582             break;
  2495             break;
  2583         }
  2496         }
  2584     return ret;
  2497     return ret;
  2585     }
  2498     }
  2586 
  2499 
  2587     
  2500 
  2588 void CFsEmailUiHtmlViewerView::ProcessAsyncCommandL( TESMRIcalViewerOperationType aCommandId,
  2501 void CFsEmailUiHtmlViewerView::ProcessAsyncCommandL( TESMRIcalViewerOperationType aCommandId,
  2589                                                      const CFSMailMessage& aMessage,
  2502                                                      const CFSMailMessage& aMessage,
  2590                                                      MESMRIcalViewerObserver* aObserver )
  2503                                                      MESMRIcalViewerObserver* aObserver )
  2591 {
  2504 {
  2592 FUNC_LOG;
  2505 FUNC_LOG;
  2716                // iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  2629                // iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  2717                 //}
  2630                 //}
  2718             }
  2631             }
  2719             break;
  2632             break;
  2720         case EESMRCmdMailComposeMessage:
  2633         case EESMRCmdMailComposeMessage:
  2721             {           
  2634             {
  2722             iAppUi.CreateNewMailL();
  2635             iAppUi.CreateNewMailL();
  2723             iOpResult.iResultCode = KErrNone;
  2636             iOpResult.iResultCode = KErrNone;
  2724             }
  2637             }
  2725             break;
  2638             break;
  2726         case EESMRCmdMailReply:
  2639         case EESMRCmdMailReply:
  2852     // Show message in standard mail viewer in case launchin MRUI fails for any
  2765     // Show message in standard mail viewer in case launchin MRUI fails for any
  2853     // other reason than viewer being cancelled by calling CancelPendingMrCommand().
  2766     // other reason than viewer being cancelled by calling CancelPendingMrCommand().
  2854     if ( aResult.iOpType == EESMRViewLaunch )
  2767     if ( aResult.iOpType == EESMRViewLaunch )
  2855         {
  2768         {
  2856         iMrUiActive = EFalse;
  2769         iMrUiActive = EFalse;
  2857         
  2770 
  2858         // load mr content to viewer so we don't end up with empty view
  2771         // load mr content to viewer so we don't end up with empty view
  2859         if (  iContainer )
  2772         if (  iContainer )
  2860              {
  2773              {
  2861              iContainer->ResetContent();
  2774              iContainer->ResetContent();
  2862              }
  2775              }
  2863                  
  2776 
  2864          if( iMessage )
  2777          if( iMessage )
  2865              {
  2778              {
  2866              TRAP_IGNORE( LoadContentFromMailMessageL( iMessage ) );  
  2779              TRAP_IGNORE( LoadContentFromMailMessageL( iMessage ) );
  2867              TRAP_IGNORE( SetMskL() );
  2780              TRAP_IGNORE( SetMskL() );
  2868              }
  2781              }
  2869         }
  2782         }
  2870     }
  2783     }
  2871 
  2784 
  2898         iAppUi.MrViewerInstanceL()->CancelOperation();
  2811         iAppUi.MrViewerInstanceL()->CancelOperation();
  2899         }
  2812         }
  2900     iMrUiActive = EFalse;
  2813     iMrUiActive = EFalse;
  2901     iMrObserverToInform = NULL;
  2814     iMrObserverToInform = NULL;
  2902     }
  2815     }
  2903     
  2816 
  2904 // -----------------------------------------------------------------------------
  2817 // -----------------------------------------------------------------------------
  2905 // CFsEmailUiHtmlViewerView::ClearMailViewer
  2818 // CFsEmailUiHtmlViewerView::ClearMailViewer
  2906 // -----------------------------------------------------------------------------
  2819 // -----------------------------------------------------------------------------
  2907 void CFsEmailUiHtmlViewerView::ClearMailViewer()
  2820 void CFsEmailUiHtmlViewerView::ClearMailViewer()
  2908     {
  2821     {
  2956     iOpenMessages = NULL;
  2869     iOpenMessages = NULL;
  2957     delete iEmbeddedMessages;
  2870     delete iEmbeddedMessages;
  2958     iEmbeddedMessages = NULL;
  2871     iEmbeddedMessages = NULL;
  2959     iMessage = NULL;
  2872     iMessage = NULL;
  2960     CancelFetchings();
  2873     CancelFetchings();
  2961    
  2874 
  2962     delete iMailBox;
  2875     delete iMailBox;
  2963     iMailBox = NULL;
  2876     iMailBox = NULL;
  2964     }
  2877     }
  2965 
  2878 
  2966 void CFsEmailUiHtmlViewerView::ReloadPageL(  ) 
  2879 void CFsEmailUiHtmlViewerView::ReloadPageL(  )
  2967     {
  2880     {
  2968     FUNC_LOG;
  2881     FUNC_LOG;
  2969     if( iContainer )
  2882     if( iContainer )
  2970         {
  2883         {
  2971         iContainer->ReloadPageL();
  2884         iContainer->ReloadPageL();
  2974 
  2887 
  2975 TBool CFsEmailUiHtmlViewerView::GetAsyncFetchStatus()
  2888 TBool CFsEmailUiHtmlViewerView::GetAsyncFetchStatus()
  2976     {
  2889     {
  2977     return ( iFetchingHtmlMessageBody || iFetchingMessageStructure || iFetchingPlainTextMessageBody );
  2890     return ( iFetchingHtmlMessageBody || iFetchingMessageStructure || iFetchingPlainTextMessageBody );
  2978     }
  2891     }
  2979     
  2892 
  2980 // ---------------------------------------------------------------------------
  2893 // ---------------------------------------------------------------------------
  2981 // CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicatorsL
  2894 // CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicatorsL
  2982 // ---------------------------------------------------------------------------
  2895 // ---------------------------------------------------------------------------
  2983 //
  2896 //
  2984 void CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicators()
  2897 void CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicators()
  2997 //
  2910 //
  2998 TBool CFsEmailUiHtmlViewerView::IsOpenedInMRViewerL()
  2911 TBool CFsEmailUiHtmlViewerView::IsOpenedInMRViewerL()
  2999     {
  2912     {
  3000     FUNC_LOG;
  2913     FUNC_LOG;
  3001     TBool retVal( EFalse );
  2914     TBool retVal( EFalse );
  3002     CFSMailMessage* msg = iAppUi.GetMailClient()->GetMessageByUidL( 
  2915     CFSMailMessage* msg = iAppUi.GetMailClient()->GetMessageByUidL(
  3003             iActivationData.iMailBoxId, iActivationData.iFolderId,
  2916             iActivationData.iMailBoxId, iActivationData.iFolderId,
  3004             iActivationData.iMessageId, EFSMsgDataEnvelope );
  2917             iActivationData.iMessageId, EFSMsgDataEnvelope );
  3005             
  2918 
  3006     if ( msg )
  2919     if ( msg )
  3007         {
  2920         {
  3008         CleanupStack::PushL( msg );
  2921         CleanupStack::PushL( msg );
  3009         if ( msg->IsFlagSet( EFSMsgFlag_CalendarMsg ) && 
  2922         if ( msg->IsFlagSet( EFSMsgFlag_CalendarMsg ) &&
  3010             iAppUi.MrViewerInstanceL() )
  2923             iAppUi.MrViewerInstanceL() )
  3011             {
  2924             {
  3012             TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
  2925             TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
  3013             mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *msg );
  2926             mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *msg );
  3014             // Opened in MR viewer if request/cancellation or unknown MR
  2927             // Opened in MR viewer if request/cancellation or unknown MR
  3015             retVal = 
  2928             retVal =
  3016                 mrMethod == EESMRMeetingRequestMethodRequest ||
  2929                 mrMethod == EESMRMeetingRequestMethodRequest ||
  3017                 mrMethod == EESMRMeetingRequestMethodCancellation ||
  2930                 mrMethod == EESMRMeetingRequestMethodCancellation ||
  3018                 mrMethod == EESMRMeetingRequestMethodUnknown;
  2931                 mrMethod == EESMRMeetingRequestMethodUnknown;
  3019             }
  2932             }
  3020         CleanupStack::PopAndDestroy( msg );
  2933         CleanupStack::PopAndDestroy( msg );
  3026 // CFsEmailUiHtmlViewerView::CopyToClipBoardL
  2939 // CFsEmailUiHtmlViewerView::CopyToClipBoardL
  3027 // -----------------------------------------------------------------------------
  2940 // -----------------------------------------------------------------------------
  3028 void CFsEmailUiHtmlViewerView::CopyCurrentToClipBoardL( const TDesC& aArgument ) const
  2941 void CFsEmailUiHtmlViewerView::CopyCurrentToClipBoardL( const TDesC& aArgument ) const
  3029     {
  2942     {
  3030     FUNC_LOG;
  2943     FUNC_LOG;
  3031     
  2944 
  3032     // Making sure that we are copying something to the clipboard 
  2945     // Making sure that we are copying something to the clipboard
  3033     if ( aArgument.Length() > 0 )
  2946     if ( aArgument.Length() > 0 )
  3034         {
  2947         {
  3035         HBufC* clipBoardText = aArgument.AllocLC();
  2948         HBufC* clipBoardText = aArgument.AllocLC();
  3036         CClipboard* cb = CClipboard::NewForWritingLC( CCoeEnv::Static()->FsSession() );
  2949         CClipboard* cb = CClipboard::NewForWritingLC( CCoeEnv::Static()->FsSession() );
  3037         cb->StreamDictionary().At( KClipboardUidTypePlainText );
  2950         cb->StreamDictionary().At( KClipboardUidTypePlainText );
  3040         plainText->InsertL( 0 , *clipBoardText );
  2953         plainText->InsertL( 0 , *clipBoardText );
  3041         plainText->CopyToStoreL( cb->Store(), cb->StreamDictionary(), 0, plainText->DocumentLength() );
  2954         plainText->CopyToStoreL( cb->Store(), cb->StreamDictionary(), 0, plainText->DocumentLength() );
  3042         CleanupStack::PopAndDestroy( plainText );
  2955         CleanupStack::PopAndDestroy( plainText );
  3043         cb->CommitL();
  2956         cb->CommitL();
  3044         CleanupStack::PopAndDestroy( cb );
  2957         CleanupStack::PopAndDestroy( cb );
  3045         CleanupStack::PopAndDestroy( clipBoardText );     
  2958         CleanupStack::PopAndDestroy( clipBoardText );
  3046         }
  2959         }
  3047     }
  2960     }
  3048 
  2961 
  3049 // --------------------------------------------------------------------------------
  2962 // --------------------------------------------------------------------------------
  3050 // CFsEmailUiHtmlViewerView::OpenLinkInBrowserL
  2963 // CFsEmailUiHtmlViewerView::OpenLinkInBrowserL
  3051 // --------------------------------------------------------------------------------
  2964 // --------------------------------------------------------------------------------
  3052 void CFsEmailUiHtmlViewerView::OpenLinkInBrowserL( const TDesC& aUrl ) const
  2965 void CFsEmailUiHtmlViewerView::OpenLinkInBrowserL( const TDesC& aUrl ) const
  3053     {
  2966     {
  3054     FUNC_LOG;
  2967     FUNC_LOG;
  3055     
  2968 
  3056     // Create session
  2969     // Create session
  3057     RApaLsSession session;
  2970     RApaLsSession session;
  3058     User::LeaveIfError( session.Connect() );
  2971     User::LeaveIfError( session.Connect() );
  3059     CleanupClosePushL( session );
  2972     CleanupClosePushL( session );
  3060      
  2973 
  3061     // Gets the default application UID for for the given MIME type
  2974     // Gets the default application UID for for the given MIME type
  3062     TUid uid;
  2975     TUid uid;
  3063     TDataType dataType( _L8( "text/html" ) );
  2976     TDataType dataType( _L8( "text/html" ) );
  3064     session.AppForDataType( dataType, uid );
  2977     session.AppForDataType( dataType, uid );
  3065      
  2978 
  3066     // Runs the default application using the dataType
  2979     // Runs the default application using the dataType
  3067     TThreadId threadId;
  2980     TThreadId threadId;
  3068     User::LeaveIfError( session.StartDocument( aUrl , dataType, threadId ) );
  2981     User::LeaveIfError( session.StartDocument( aUrl , dataType, threadId ) );
  3069      
  2982 
  3070     CleanupStack::PopAndDestroy(); // session
  2983     CleanupStack::PopAndDestroy(); // session
  3071 }
  2984 }
  3072 
  2985 
  3073 // --------------------------------------------------------------------------------
  2986 // --------------------------------------------------------------------------------
  3074 // CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL
  2987 // CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL
  3075 // --------------------------------------------------------------------------------
  2988 // --------------------------------------------------------------------------------
  3076 void CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL( const TDesC& aUrl ) const
  2989 void CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL( const TDesC& aUrl ) const
  3077     {
  2990     {
  3078     FUNC_LOG;
  2991     FUNC_LOG;
  3079     HBufC* url = aUrl.AllocLC();
  2992     HBufC* url = aUrl.AllocLC();
  3080     
  2993 
  3081     RFavouritesSession fSession;
  2994     RFavouritesSession fSession;
  3082     User::LeaveIfError( fSession.Connect() );
  2995     User::LeaveIfError( fSession.Connect() );
  3083     CleanupClosePushL( fSession );
  2996     CleanupClosePushL( fSession );
  3084 
  2997 
  3085     RFavouritesDb favourites;
  2998     RFavouritesDb favourites;
  3106     CleanupStack::PopAndDestroy( favouritesItem );
  3019     CleanupStack::PopAndDestroy( favouritesItem );
  3107     CleanupStack::PopAndDestroy( &favourites );
  3020     CleanupStack::PopAndDestroy( &favourites );
  3108     CleanupStack::PopAndDestroy( &fSession );
  3021     CleanupStack::PopAndDestroy( &fSession );
  3109 
  3022 
  3110     CleanupStack::PopAndDestroy( url );
  3023     CleanupStack::PopAndDestroy( url );
  3111     
  3024 
  3112     if ( error == KErrNone )
  3025     if ( error == KErrNone )
  3113         {
  3026         {
  3114         TFsEmailUiUtility::ShowInfoNoteL(
  3027         TFsEmailUiUtility::ShowInfoNoteL(
  3115             R_FREESTYLE_EMAIL_UI_VIEWER_BOOKMARK_ADDED, ETrue );
  3028             R_FREESTYLE_EMAIL_UI_VIEWER_BOOKMARK_ADDED, ETrue );
  3116         }
  3029         }
  3120             R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
  3033             R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
  3121         }
  3034         }
  3122     }
  3035     }
  3123 
  3036 
  3124 /*
  3037 /*
  3125  * Delaying the fetch for MfE till the user scrolls to the bottom of 
  3038  * Delaying the fetch for MfE till the user scrolls to the bottom of
  3126  * the message. 
  3039  * the message.
  3127  */
  3040  */
  3128 void CFsEmailUiHtmlViewerView::StartFetchingMessageL()
  3041 void CFsEmailUiHtmlViewerView::StartFetchingMessageL()
  3129     {
  3042     {
  3130 	if( iMessage )
  3043 	if( iMessage )
  3131 	    {
  3044 	    {
  3137            }
  3050            }
  3138         else
  3051         else
  3139            {
  3052            {
  3140            type = EMessagePlainTextBodyPart;
  3053            type = EMessagePlainTextBodyPart;
  3141            }
  3054            }
  3142          
  3055 
  3143               
  3056 
  3144         if ( !MessagePartFullyFetchedL( type ))
  3057         if ( !MessagePartFullyFetchedL( type ))
  3145            {
  3058            {
  3146            iAsyncProcessComplete = EFalse;
  3059            iAsyncProcessComplete = EFalse;
  3147            iStartAsyncFetchType = type;
  3060            iStartAsyncFetchType = type;
  3148            //check to make sure we don't kick off fetch twice for the cases where bodypart 
  3061            //check to make sure we don't kick off fetch twice for the cases where bodypart
  3149            //not found(OZ)
  3062            //not found(OZ)
  3150            if(iMessage && !GetAsyncFetchStatus())
  3063            if(iMessage && !GetAsyncFetchStatus())
  3151                {
  3064                {
  3152                StartFetchingMessagePartL( *iMessage, type );
  3065                StartFetchingMessagePartL( *iMessage, type );
  3153                }
  3066                }
  3162         CFSMailMessagePart* bodyPart = iMessage->HtmlBodyPartL();
  3075         CFSMailMessagePart* bodyPart = iMessage->HtmlBodyPartL();
  3163         if ( !bodyPart )
  3076         if ( !bodyPart )
  3164             {
  3077             {
  3165             bodyPart = iMessage->PlainTextBodyPartL();
  3078             bodyPart = iMessage->PlainTextBodyPartL();
  3166             }
  3079             }
  3167         
  3080 
  3168         if ( bodyPart )
  3081         if ( bodyPart )
  3169             {
  3082             {
  3170             aMessageBodyStructurePresent = ETrue;
  3083             aMessageBodyStructurePresent = ETrue;
  3171             CleanupStack::PushL( bodyPart );
  3084             CleanupStack::PushL( bodyPart );
  3172     
  3085 
  3173             if ( bodyPart->FetchedContentSize() == 0 && bodyPart->ContentSize() != 0 )
  3086             if ( bodyPart->FetchedContentSize() == 0 && bodyPart->ContentSize() != 0 )
  3174                 {
  3087                 {
  3175                 aMessageBodyContentPresent = EFalse;
  3088                 aMessageBodyContentPresent = EFalse;
  3176                 }
  3089                 }
  3177             else
  3090             else
  3178                 {
  3091                 {
  3179                 aMessageBodyContentPresent = ETrue;
  3092                 aMessageBodyContentPresent = ETrue;
  3180                 }
  3093                 }
  3181             
  3094 
  3182             CleanupStack::PopAndDestroy( bodyPart );
  3095             CleanupStack::PopAndDestroy( bodyPart );
  3183             }
  3096             }
  3184         else
  3097         else
  3185             {
  3098             {
  3186             aMessageBodyStructurePresent = EFalse;
  3099             aMessageBodyStructurePresent = EFalse;
  3275     FUNC_LOG;
  3188     FUNC_LOG;
  3276     TInt err( KErrNone );
  3189     TInt err( KErrNone );
  3277     return err;
  3190     return err;
  3278     }
  3191     }
  3279 
  3192 
  3280 CFlagSelectionNoteHandler::CFlagSelectionNoteHandler(  CFsEmailUiHtmlViewerView& aViewerVisualiser )
  3193 CFlagSelectionNoteHandler::CFlagSelectionNoteHandler( CFsEmailUiHtmlViewerView& aViewerVisualiser )
  3281     : CActive ( EPriorityHigh ),
  3194     : CActive ( EPriorityHigh ),
  3282     iViewerView( aViewerVisualiser )
  3195     iViewerView( aViewerVisualiser )
  3283     {
  3196     {
  3284     FUNC_LOG;
  3197     FUNC_LOG;
  3285     CActiveScheduler::Add( this );
  3198     CActiveScheduler::Add( this );