emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h
branchRCL_3
changeset 64 3533d4323edc
child 80 726fba06891a
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CFsEmailUiHtmlViewerView class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __FREESTYLEEMAILUI_HTML_VIEWER_VIEW_H__
       
    21 #define __FREESTYLEEMAILUI_HTML_VIEWER_VIEW_H__
       
    22 
       
    23 #include <cstack.h>
       
    24 #include "mfsmailrequestobserver.h"
       
    25 #include "mesmricalviewercallback.h"
       
    26 #include "mesmricalviewerobserver.h"
       
    27 #include "FreestyleEmailUiViewBase.h"
       
    28 #include "FreestyleEmailUiConstants.h"
       
    29 #include "FreestyleEmailUiContactHandlerObserver.h"
       
    30 #include "FreestyleEmailUiAttachmentsListModel.h"
       
    31 #include <AknWaitDialog.h>
       
    32 #include "FreestyleEmailDownloadInformationMediator.h"
       
    33 #include "FreestyleEmailUiControlBarCallback.h"
       
    34 
       
    35 class CFSMailMessage;
       
    36 class CFreestyleEmailUiAppUi;
       
    37 class CFsEmailUiHtmlViewerContainer;
       
    38 class CFreestyleMessageHeaderURL;
       
    39 class CAknWaitDialog; //<cmail>
       
    40 class CFlagSelectionNoteHandler;
       
    41 class CAknGlobalListQuery;
       
    42 class CAknGlobalNote;
       
    43 /**
       
    44  * Html viewer view.
       
    45  */
       
    46 class CFsEmailUiHtmlViewerView : public CFsEmailUiViewBase,
       
    47         public MFSEmailUiContactHandlerObserver,
       
    48         public MFSEmailUiAttachmentsStatusObserver,
       
    49         public MFSEmailDownloadInformationObserver,
       
    50         public MFSMailRequestObserver,
       
    51         public MProgressDialogCallback,
       
    52 		public MFSEmailUiFolderListCallback,
       
    53 		public MESMRIcalViewerCallback,
       
    54     	public MESMRIcalViewerObserver
       
    55     {
       
    56 public:
       
    57 
       
    58     /** Two-phased constructor. */
       
    59     static CFsEmailUiHtmlViewerView* NewL( CAlfEnv& aEnv,
       
    60                                            CFreestyleEmailUiAppUi& aAppUi,
       
    61                                            CAlfControlGroup& aControlGroup );
       
    62 
       
    63     /** Destructor. */
       
    64     ~CFsEmailUiHtmlViewerView();
       
    65 
       
    66 public:  // from CAknView
       
    67 
       
    68     /**
       
    69     * Id
       
    70     * @return Id Uid value
       
    71     */
       
    72     TUid Id() const;
       
    73 
       
    74 
       
    75     void HandleViewRectChange();
       
    76 
       
    77     /**
       
    78     * HandleCommandL
       
    79     * From CAknView, takes care of command handling.
       
    80     * @param aCommand Command to be handled
       
    81     */
       
    82     void HandleCommandL( TInt aCommand );
       
    83 
       
    84     // Handle accept/decline/tentative/remove commands given for meeting request message directly from list UI.
       
    85 	void HandleMrCommandL( TInt aCommandId, TFSMailMsgId aMailboxId, TFSMailMsgId aFolderId, TFSMailMsgId aMessageId );
       
    86 
       
    87 	void CompletePendingMrCommand();
       
    88 	void CancelPendingMrCommandL();
       
    89 
       
    90     /**
       
    91     * ChildDoDeactivate
       
    92     * From CFsEmailUiViewBase, deactivate the AknView
       
    93     * Remove the container class instance from the App UI's stack and
       
    94     * deletes the instance
       
    95     */
       
    96     void ChildDoDeactivate();
       
    97 
       
    98     /**
       
    99     * DoExitL
       
   100     * Handler called when exiting the view.
       
   101     */
       
   102     void DoExitL();
       
   103 
       
   104     void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
   105 
       
   106     void SetMskL();
       
   107     void PrepareForExit();
       
   108 
       
   109 public : // for MFSMailRequestObserver
       
   110     void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
       
   111 
       
   112 public:
       
   113     // from MProgressDialogCallback
       
   114     void DialogDismissedL( TInt aButtonId);
       
   115 
       
   116     CFSMailMessage* CurrentMessage();
       
   117     CFSEmailUiAttachmentsListModel* CurrentAttachmentsListModel();
       
   118 
       
   119     // Return view area that can be used for container
       
   120     TRect ContainerRect() const;
       
   121 
       
   122 public:
       
   123     void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType );
       
   124     void HandleMailBoxEventL( TFSMailEvent aEvent,
       
   125                               TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ );
       
   126 
       
   127     void HandleEmailAddressCommandL( TInt aCommand, const TDesC& aEmailAddress );
       
   128     void HandleWebAddressCommandL( TInt aCommand, const TDesC& aUrl );
       
   129 
       
   130     void DownloadAttachmentL( const TAttachmentData& aAttachment );
       
   131     void DownloadAllAttachmentsL();
       
   132     void CancelAttachmentL( const TAttachmentData& aAttachment );
       
   133     void CancelAllAttachmentsL();
       
   134     void OpenAttachmentL( const TAttachmentData& aAttachment );
       
   135     void SaveAttachmentL( const TAttachmentData& aAttachment );
       
   136     void SaveAllAttachmentsL();
       
   137     void RemoveAttachmentContentL( const TAttachmentData& aAttachment );
       
   138     void OpenAttachmentsListViewL();
       
   139     TBool IsEmbeddedMsgView();
       
   140     TBool IsEmbeddedMsgSavingAllowed();
       
   141     // Helper funcitons to get viewed message ID and Folder id
       
   142     TFSMailMsgId ViewedMessageFolderId();
       
   143     TFSMailMsgId ViewedMessageId();
       
   144 
       
   145     TBool GetAsyncFetchStatus();
       
   146     void StartFetchingMessageL();
       
   147     void ReloadPageL();
       
   148 public: // from MFSEmailUiContactHandlerObserver
       
   149     void OperationCompleteL( TContactHandlerCmd aCmd,
       
   150                              const RPointerArray<CFSEmailUiClsItem>& aContacts );
       
   151     void OperationErrorL( TContactHandlerCmd, TInt aError );
       
   152     TBool IsRemoteLookupSupportedL();
       
   153 
       
   154 public : // from MFSEmailDownloadInformationObserver
       
   155     void RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart );
       
   156 
       
   157 public: // from MFSEmailUiAttachmentsStatusObserver
       
   158     void DownloadStatusChangedL( TInt aIndex );
       
   159 
       
   160 public: // from MESMRIcalViewerCallback
       
   161     void ProcessAsyncCommandL( TESMRIcalViewerOperationType aCommandId,	const CFSMailMessage& aMessage, MESMRIcalViewerObserver* aObserver = NULL );
       
   162 	  void ProcessSyncCommandL( TESMRIcalViewerOperationType aCommandId, const CFSMailMessage& aMessage );
       
   163     TBool CanProcessCommand( TESMRIcalViewerOperationType aCommandId  ) const;
       
   164 
       
   165 public: // from MESMRIcalViewerObserver
       
   166     void OperationCompleted( TIcalViewerOperationResult aResult );
       
   167     void OperationError( TIcalViewerOperationResult aResult );
       
   168 
       
   169     void FadeOut(TBool aDirectionOut);
       
   170 
       
   171 private: // from
       
   172     /**
       
   173      * @see CFsEmailUiViewBase::ChildDoActivateL
       
   174      */
       
   175     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
       
   176                            TUid aCustomMessageId,
       
   177                            const TDesC8& aCustomMessage );
       
   178 
       
   179     /**
       
   180      * @see CFsEmailUiViewBase::NavigateBackL
       
   181      */
       
   182     void NavigateBackL();
       
   183 
       
   184     /**
       
   185      * @see CFsEmailUiViewBase::ChangeMskCommandL
       
   186      */
       
   187     void ChangeMskCommandL( TInt aLabelResourceId );
       
   188 
       
   189     /**
       
   190      * @see CFsEmailUiViewBase::IsStatusPaneVisible
       
   191      */
       
   192     TBool IsStatusPaneVisible() const;
       
   193 
       
   194     /**
       
   195 	 * @see CFsEmailUiViewBase::SetStatusBarLayout
       
   196 	 */
       
   197     void SetStatusBarLayout();
       
   198 
       
   199 private: // New functions
       
   200 
       
   201     // list of different types of content
       
   202     enum TFetchedType
       
   203         {
       
   204         EMessagePlainTextBodyPart = 0,
       
   205         EMessageHtmlBodyPart,
       
   206         EMessageStructure
       
   207         };
       
   208     void ClearMailViewer();
       
   209     void LoadContentFromFileL( const TDesC& aFileName );
       
   210     void LoadContentFromFileL( RFile& aFile );
       
   211     void LoadContentFromUrlL( const TDesC& aUrl );
       
   212     void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage, TBool aResetScrollPosition =ETrue );
       
   213     static TInt DeleteMail( TAny* aSelf );
       
   214     void DeleteMailL(TBool aSilentDelete = EFalse);
       
   215     void HideContainer();
       
   216     void ShowContainerL();
       
   217     void DynInitZoomMenuL( CEikMenuPane* aMenuPane );
       
   218     TInt ZoomLevelIndexL();
       
   219     void SetZoomLevelIndexL( TInt aIndex );
       
   220     void SaveEmailAsContactL(
       
   221         const TDesC& aEmailAddress );
       
   222     //new functions for support of HTML viewer
       
   223     void CallAdressL( const TDesC& aEmailAddress, TBool aVideoCall );
       
   224     void OpenContactDetailsL( const TDesC& aEmailAddress );
       
   225     void LaunchRemoteLookupL( const TDesC& aEmailAddress );
       
   226     void CreateMessageL( const TDesC& aEmailAddress );
       
   227 
       
   228     void UpdateDownloadIndicatorL( const TPartData& aPart,
       
   229                                    const TFSProgress& aEvent );
       
   230     //fetching related API
       
   231     TBool MessagePartFullyFetchedL( TFetchedType aFetchedContentType ) const;
       
   232     void StartFetchingMessagePartL( CFSMailMessage& aMessagePtr,
       
   233                                                 TFetchedType aFetchedContentType );
       
   234     void UpdateMessagePtrL( TFSMailMsgId aNewMailboxId,
       
   235                                                             TFSMailMsgId aNewFolderId,
       
   236                                                             TFSMailMsgId aNewMessageId );
       
   237     void CancelFetchings();
       
   238     void StartFetchingMessageStructureL( CFSMailMessage& aMsg );
       
   239     TBool MessageStructureKnown( CFSMailMessage& aMsg ) const;
       
   240     void StartWaitedFetchingL( TFetchedType aFetchedContentType );
       
   241     // Message stack handling. Ownership of message is transferred when succesful.
       
   242     void PushMessageL( CFSMailMessage* aMessage, TBool aIsEmbedded );
       
   243     CFSMailMessage* PopMessage();
       
   244     void EraseMessageStack();
       
   245     TBool OpenFolderListForMessageMovingL();
       
   246     void ShowPreviousMessageL();
       
   247     TBool ShowPreviousMessageMenuInOptions() const;
       
   248     void ShowNextMessageL();
       
   249     TBool ShowNextMessageMenuInOptions() const;
       
   250     void ChangeMsgReadStatusL(TBool aRead, TBool aCmdFromMrui );
       
   251     void SetMessageFollowupFlagL();
       
   252     void SendEventToAppUiL( TFSMailEvent aEventType );
       
   253     // Message is moved and viewer is closed asynchronously after selecting a folder
       
   254       // from the move to folder dialog. This is necessary because view swithching is asynchronous.
       
   255     static TInt MoveToFolderAndExitL( TAny* aMailViewerVisualiser );
       
   256     void FolderSelectedL( TFSMailMsgId aSelectedFolderId,
       
   257                           TFSEmailUiCtrlBarResponse aResponse );
       
   258 
       
   259     void UpdateEmailHeaderIndicators();
       
   260     TBool IsOpenedInMRViewerL();
       
   261     void CopyCurrentToClipBoardL( const TDesC& aArgument) const;
       
   262     void OpenLinkInBrowserL( const TDesC& aUrl) const;
       
   263     void SaveWebAddressToFavouritesL( const TDesC& aUrl ) const;
       
   264     void SetScrollPosition(TInt aPosition);
       
   265 
       
   266     void CheckMessageBodyL( CFSMailMessage& aMessage, TBool& aMessageBodyStructurePresent, TBool& aMessageBodyContentPresent);
       
   267 
       
   268 private: // Constructors
       
   269 
       
   270     void ConstructL();
       
   271     CFsEmailUiHtmlViewerView( CAlfEnv& aEnv,
       
   272                               CFreestyleEmailUiAppUi& aAppUi,
       
   273                               CAlfControlGroup& aControlGroup );
       
   274 
       
   275 private:
       
   276     CAlfEnv& iEnv;
       
   277     CFsEmailUiHtmlViewerContainer* iContainer;
       
   278     CFSMailMessage* iMessage;
       
   279     THtmlViewerActivationData iActivationData;
       
   280     CFSEmailUiAttachmentsListModel* iAttachmentsListModel;
       
   281 
       
   282     // Stack of open messages. Messages are owned by this stack.
       
   283     CStack<CFSMailMessage, ETrue>* iOpenMessages;
       
   284     // Stack of embedded messages. Message are NOT owned by this stack. Similar to iOpenMessages
       
   285     // but has NULL pointer in slots which correspond non-embedded messages.
       
   286     CStack<CFSMailMessage, EFalse>* iEmbeddedMessages;
       
   287     TBool iCreateNewMsgFromEmbeddedMsg;
       
   288 
       
   289     // <cmail>
       
   290     // Temporary mail address for opening editor
       
   291     CFSMailAddress* iNewMailTempAddress;
       
   292     // </cmail>
       
   293     CFSMailBox* iMailBox;
       
   294 private: // data for moving message to different folder action
       
   295     TBool iFetchingMessageStructure;
       
   296     TInt iCurrentStructureFetchRequestId;
       
   297 
       
   298     TBool iFetchingPlainTextMessageBody;
       
   299     TInt iCurrentPlainTextBodyFetchRequestId;
       
   300 
       
   301     TBool iFetchingHtmlMessageBody;
       
   302     TInt iCurrentHtmlBodyFetchRequestId;
       
   303 
       
   304     TFetchedType iStartAsyncFetchType;
       
   305 
       
   306     // <cmail>
       
   307     // Email forwarding initiated (so don't cancel fetch of message parts
       
   308     // during deactivation).
       
   309     TBool iForwardingMessage;
       
   310     // </cmail>
       
   311 
       
   312     // Wait note stuff
       
   313     //<cmail>
       
   314     //CAknWaitNoteWrapper* iAsyncWaitNote;
       
   315     CAknWaitDialog* iWaitDialog;
       
   316     CAknWaitDialog* iWaitDialogOpening;
       
   317     TBool iDialogNotDismissed;
       
   318     //</cmail>
       
   319     TBool iFetchingAlready;
       
   320     TBool iAsyncProcessComplete;
       
   321     CActiveSchedulerWait iWait;
       
   322 	TBool iMoveToFolderOngoing;
       
   323     TBool iMovingMeetingRequest;
       
   324     CAsyncCallBack* iAsyncCallback;
       
   325 
       
   326     TFSMailMsgId iMoveDestinationFolder;
       
   327     	// Meeting request observer stuff.
       
   328 		// Pointer to observer to inform, not owned.
       
   329 		MESMRIcalViewerObserver* iMrObserverToInform;
       
   330 		MESMRIcalViewerObserver::TIcalViewerOperationResult iOpResult;
       
   331 		TBool iMrUiActive;
       
   332 	  //<cmail>
       
   333     // Message pointer to a deleted mail from Mrui
       
   334     TFSMailMsgId iDeletedMessageFromMrui;
       
   335     // Flag selection handler active object for global note
       
   336     CFlagSelectionNoteHandler* iFlagSelectionHandler;
       
   337     TBool iNextOrPrevMessageSelected;
       
   338     TBool iMessageIsDeleted;
       
   339 
       
   340     // Id of last deleted message
       
   341     TFSMailMsgId iLastDeletedMessageID;
       
   342     };
       
   343 
       
   344 ////////////////////////////////////////
       
   345 // FLAG selection dialog global note handler
       
   346 /////////////////////////////////////////
       
   347 class CFlagSelectionNoteHandler : public CActive
       
   348     {
       
   349     public:  // Constructors and destructor
       
   350         static CFlagSelectionNoteHandler* NewL( CFsEmailUiHtmlViewerView& aViewerVisualiser );
       
   351         virtual ~CFlagSelectionNoteHandler();
       
   352         void Cancel();
       
   353         void LaunchFlagListQueryDialogL();
       
   354 
       
   355     private:
       
   356 
       
   357         void RunL();
       
   358         void DoCancel();
       
   359         TInt RunError( TInt aError );
       
   360 
       
   361     private:
       
   362         CFlagSelectionNoteHandler(  CFsEmailUiHtmlViewerView& aVoIPDialogObserver );
       
   363 
       
   364 
       
   365     private:
       
   366         CFsEmailUiHtmlViewerView& iViewerView;
       
   367         CAknGlobalListQuery* iGlobalFlagQuery;
       
   368         HBufC* iPrompt;
       
   369         TInt iSelection;
       
   370     };
       
   371 
       
   372 
       
   373 #endif // __FREESTYLEEMAILUI_HTML_VIEW_H__