webengine/osswebengine/WebCore/platform/network/symbian/SelfDownloadContentHandler.h
changeset 0 dd21522fd290
child 17 c8a366e56285
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 the License "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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SELFDOWNLOADCONTENTHANDLER_H
       
    20 #define SELFDOWNLOADCONTENTHANDLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <apparc.h>
       
    25 #include <http/rhttptransaction.h>
       
    26 #include <http/MHTTPTransactionCallback.h>
       
    27 #include <f32file.h>
       
    28 
       
    29 _LIT8( KSelfDownloadCallback, "SelfDownloadCallback" );
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CDocumentHandler;
       
    33 class TDataType;
       
    34 class MBrCtlSpecialLoadObserver;
       
    35 class WebFrame;
       
    36 namespace WebCore {
       
    37     class ResourceHandle;
       
    38     struct ResourceRequest;
       
    39     class ResourceResponse;
       
    40 }
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *
       
    46 *  @lib 
       
    47 *  @since 3.0
       
    48 */
       
    49 class CTempFile : public CBase
       
    50     {
       
    51     public:   // Constructors and destructor
       
    52 
       
    53         /**
       
    54           * Two-phased constructor.
       
    55           */
       
    56         static CTempFile* NewL(HBufC* aFileName = NULL);
       
    57 
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         ~CTempFile( void );
       
    62 
       
    63     public:  // New functions
       
    64 
       
    65         /**
       
    66         *
       
    67         * @since 3.0
       
    68         * @param
       
    69         * @return number of bytes written
       
    70         */
       
    71         TInt WriteL( const TDesC8& aFileData );
       
    72 
       
    73         /**
       
    74         *
       
    75         * @since 3.0
       
    76         * @param
       
    77         * @return number of bytes written
       
    78         */
       
    79         void CloseL( void );
       
    80 
       
    81         /**
       
    82         *
       
    83         * @since 3.0
       
    84         * @param
       
    85         * @return void
       
    86         */
       
    87         const TDesC& Name( void ) const;
       
    88 
       
    89     private:
       
    90 
       
    91         /**
       
    92         * C++ default constructor.
       
    93         */
       
    94         CTempFile( void );
       
    95 
       
    96         /**
       
    97         * By default Symbian 2nd phase constructor is private.
       
    98         */
       
    99         void ConstructL(HBufC* aFileName);
       
   100 
       
   101     public:      // Data
       
   102 
       
   103     protected:   // Data
       
   104 
       
   105     private:     // Data
       
   106 
       
   107         HBufC* iFileName;
       
   108 
       
   109         RFs iFsSession;
       
   110         
       
   111         RFile iFile;
       
   112        
       
   113     };
       
   114 
       
   115 
       
   116 /**
       
   117 *
       
   118 *  @since 5.0
       
   119 */
       
   120 class SelfDownloadContentHandler : public MHTTPTransactionCallback
       
   121     {
       
   122     public:  // Constructors and destructor        
       
   123         
       
   124         /**
       
   125         * Two-phased constructor.
       
   126         */
       
   127         static SelfDownloadContentHandler* NewL(WebFrame* webFrame, TDesC& selfDownloadTypes);
       
   128         
       
   129         /**
       
   130         * Destructor.
       
   131         */
       
   132         virtual ~SelfDownloadContentHandler();
       
   133 
       
   134     public: // from MHTTPTransactionCallback
       
   135 
       
   136         void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
       
   137 
       
   138         TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
       
   139 
       
   140     public: // New functions
       
   141     
       
   142         TInt IsSupported(const WebCore::ResourceRequest& request,
       
   143             const WebCore::ResourceResponse& response, RHTTPTransaction& httpTransaction);
       
   144 
       
   145         TInt HandleResponseHeadersL(const WebCore::ResourceRequest& request,
       
   146             const WebCore::ResourceResponse& response, RHTTPTransaction& httpTransaction);
       
   147 
       
   148         TInt HandleResponseBodyL(RHTTPTransaction& httpTransaction);
       
   149 
       
   150         TInt ResponseCompleteL(RHTTPTransaction httpTransaction, TInt error);
       
   151         //This method reinitialize the special loader reference this static class.
       
   152         void ReinitializeSpecialLoadObserver(WebFrame* webFrame);
       
   153 
       
   154     private:
       
   155 
       
   156         /**
       
   157         * C++ default constructor.
       
   158         */
       
   159         SelfDownloadContentHandler(WebFrame* webFrame);
       
   160 
       
   161         /**
       
   162         * By default Symbian 2nd phase constructor is private.
       
   163         */
       
   164         void ConstructL(WebFrame* webFrame, TDesC& selfDownloadTypes);
       
   165 
       
   166         void HandleError(/* TInt aTransactionId,*/ TInt aError);
       
   167 
       
   168         TBool IsSelfDownloadContent(TDesC& contentType);
       
   169 
       
   170 //        TBool RecognizeContentTypeL(TPtr aContentType);
       
   171 
       
   172     private:    // Data
       
   173 
       
   174         WebFrame* m_WebFrame;
       
   175         //
       
   176         // file containing the response content - this should be deleted
       
   177         // and a new one created for each response.
       
   178         CTempFile*      m_ContentFile;                      // owned
       
   179         //
       
   180         HBufC*          m_ContentType;                      // owned
       
   181         //
       
   182         HBufC*          m_Charset;                          // owned
       
   183         //
       
   184         HBufC*          m_ReqUrl;                           // owned
       
   185         //
       
   186         MBrCtlSpecialLoadObserver* m_SpecialLoadObserver;   // not owned
       
   187         //
       
   188         HBufC*          m_SelfDlMimeTypes;                  // owned
       
   189     };
       
   190 
       
   191 #endif      // SELFDOWNLOADCONTENTHANDLER_H
       
   192             
       
   193 // End of File