emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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:  CFsEmailUiHtmlViewerContainer class definition
       
    15 *
       
    16 */
       
    17  
       
    18 
       
    19 
       
    20 #ifndef __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__
       
    21 #define __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__
       
    22 
       
    23 
       
    24 #include <coecntrl.h>
       
    25 #include <BrCtlSpecialLoadObserver.h>
       
    26 #include <BrCtlLinkResolver.h>
       
    27 
       
    28 #include "FreestyleEmailDownloadInformationMediator.h"
       
    29 
       
    30 class CFSMailMessage;
       
    31 class CFreestyleEmailUiAppUi;
       
    32 class CFreestyleMessageHeaderURLEventHandler;
       
    33 
       
    34 /**
       
    35  * Html viewer container.
       
    36  */
       
    37 class CFsEmailUiHtmlViewerContainer : public CCoeControl,
       
    38                                       public MBrCtlSpecialLoadObserver,
       
    39                                       public MBrCtlLinkResolver,
       
    40                                       public MBrCtlSoftkeysObserver,
       
    41                                       public MFSEmailDownloadInformationObserver
       
    42     {
       
    43 public:
       
    44 
       
    45     /** Two-phased constructor. */
       
    46     static CFsEmailUiHtmlViewerContainer* NewL( CFreestyleEmailUiAppUi& aAppUi,
       
    47         CFsEmailUiHtmlViewerView& aView );
       
    48     /** Destrcutor. */
       
    49     ~CFsEmailUiHtmlViewerContainer();
       
    50 
       
    51     CBrCtlInterface* BrowserControlIf();
       
    52     void LoadContentFromFileL( const TDesC& aFileName );
       
    53     void LoadContentFromFileL( RFile& aFile );
       
    54     void LoadContentFromUrlL( const TDesC& aUrl );
       
    55     void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage );
       
    56     void ResetContent();
       
    57     void CancelFetch();
       
    58     void ClearCacheAndLoadEmptyContent();
       
    59     // <cmail>
       
    60     void PrepareForExit();
       
    61     // </cmail>
       
    62     
       
    63 // from base class CCoeControl
       
    64 
       
    65     CCoeControl* ComponentControl( TInt aIndex ) const;
       
    66     TInt CountComponentControls() const;
       
    67     void Draw( const TRect& aRect ) const;
       
    68     void SizeChanged();
       
    69     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
    70 
       
    71 // from base class MBrCtlSpecialLoadObserver
       
    72 
       
    73     void NetworkConnectionNeededL( TInt* aConnectionPtr, TInt* aSockSvrHandle,
       
    74         TBool* aNewConn, TApBearerType* aBearerType );
       
    75     TBool HandleRequestL( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray );
       
    76     TBool HandleDownloadL( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray );
       
    77 
       
    78 // from base class MFSEmailDownloadInformationObserver
       
    79 
       
    80     void RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart );
       
    81 
       
    82 // from base class MBrCtlLinkResolver
       
    83 
       
    84     TBool ResolveEmbeddedLinkL( const TDesC& aEmbeddedUrl,
       
    85         const TDesC& aCurrentUrl, TBrCtlLoadContentType aLoadContentType, 
       
    86         MBrCtlLinkContent& aEmbeddedLinkContent ); 
       
    87     TBool ResolveLinkL( const TDesC& aUrl, const TDesC& aCurrentUrl,
       
    88         MBrCtlLinkContent& aBrCtlLinkContent );
       
    89     void CancelAll();
       
    90 
       
    91 // from base class MBrCtlSoftkeysObserver
       
    92 
       
    93     void UpdateSoftkeyL( TBrCtlKeySoftkey aKeySoftkey, const TDesC& aLabel,
       
    94         TUint32 aCommandId, TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason );
       
    95     void StopObserving();
       
    96 private:
       
    97 
       
    98     // Second phase constructor.
       
    99     void ConstructL();
       
   100     // C++ constructor.
       
   101     CFsEmailUiHtmlViewerContainer( CFreestyleEmailUiAppUi& aAppUi,
       
   102         CFsEmailUiHtmlViewerView& aView );
       
   103 
       
   104     // Set HTML folder path name
       
   105     void SetHtmlFolderPathL();
       
   106     // Sets temporary HTML folder path name
       
   107     void SetTempHtmlFolderPath();
       
   108     // Remove all previously created files from temporary HTML folder
       
   109     void EmptyTempHtmlFolderL();
       
   110     // Copies given file to temporary HTML folder and returns an open file
       
   111     // handle to the created copy.
       
   112 // <cmail>
       
   113     void CopyFileToHtmlFileL( RFile& aFile, const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart );
       
   114     // Reads given file content to buffer and return pointer to it
       
   115     HBufC8* ReadContentFromFileLC( RFile& aFile );
       
   116     // Writes buffer to given file
       
   117     void WriteContentToFileL( const TDesC8& aContent, const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart );
       
   118 // </cmail>
       
   119     // Finds the attachment from the list that matches the given content ID 
       
   120     CFSMailMessagePart* MatchingAttacmentL( const TDesC& aContentId,
       
   121         const RPointerArray<CFSMailMessagePart>& aAttachments ) const;
       
   122     // Resolves embedded link referring to file in temporary HTML folder
       
   123     TBool ResolveLinkL( const TDesC& aLink, TBool aContentId,
       
   124         MBrCtlLinkContent& aEmbeddedLinkContent );
       
   125     // Downloads and return attachment content via MBrCtlLinkContent interface
       
   126     void DownloadAttachmentL( CFSMailMessagePart& aAttachment,
       
   127         MBrCtlLinkContent& aEmbeddedLinkContent );
       
   128     
       
   129     void SetHTMLResourceFlagFullName();
       
   130     void EnableHTMLResourceFlagL();
       
   131     TBool HTMLResourceFlagEnabled();
       
   132     void CopyHTMLResourceL();
       
   133     // Ensure all resource files (eg. images) required by HTML display to be ready in C:\[private]\HtmlFile
       
   134     void EnsureHTMLResourceL(); 
       
   135     void ConvertPlainTextToHTML(CFSMailMessagePart* aTextBodyPart, RFile htmlFile);
       
   136     void CopyFileToHtmlFileL( const TDesC8& aBuffer,
       
   137             const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart );
       
   138     void ConvertToHTML( const TDesC8& aContent,
       
   139             const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart );
       
   140     HBufC8* GetCharacterSetL( CFSMailMessagePart& aHtmlBodyPart );
       
   141     
       
   142 
       
   143 private: // data
       
   144 
       
   145     // Reference to AppUi.
       
   146     CFreestyleEmailUiAppUi& iAppUi;
       
   147     // Reference to Html viewer view.
       
   148     CFsEmailUiHtmlViewerView& iView;
       
   149     // Browser control interface. Own.
       
   150     CBrCtlInterface* iBrCtlInterface;
       
   151     // Message. Not own.
       
   152     CFSMailMessage*  iMessage;
       
   153     RFile            iFile;
       
   154     RFs              iFs;
       
   155     RSocketServ      iSocketServer;
       
   156     RConnection      iConnection;
       
   157     TBool            iFirstTime;
       
   158     
       
   159     // HTML folder path.
       
   160     TPath iHtmlFolderPath;
       
   161     // Temporary HTML folder path.
       
   162     TPath iTempHtmlFolderPath;
       
   163     // HTML resource flag file path
       
   164     TPath iHtmlResourceFlagPath;
       
   165     
       
   166     // Interfaces waiting for embedded link content.
       
   167     RPointerArray<MBrCtlLinkContent> iLinkContents;
       
   168     // Message parts being downloaded as embedded link content.
       
   169     RArray<TPartData> iMessageParts;
       
   170     CFreestyleMessageHeaderURLEventHandler* iEventHandler;
       
   171     TBool iObservingDownload;
       
   172     };
       
   173 
       
   174 
       
   175 #endif // __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__