internetradio2.0/dataproviderinc/irhttpdataprovider.h
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IRHTTPDATAPROVIDER_H
       
    20 #define IRHTTPDATAPROVIDER_H
       
    21 
       
    22 #include <mhttptransactioncallback.h>
       
    23 #include <rhttpsession.h>
       
    24 
       
    25 #include "irdataproviderconstants.h"
       
    26 #include "irfavoritesdb.h"
       
    27 
       
    28 class CIRHttpPost;
       
    29 class CIRHttpRequestData;
       
    30 class CIRNetworkController;
       
    31 class CIRLogoDownloadEngine;
       
    32 class CIRFavoritesDb;
       
    33 class MIRHttpDataProviderObserver;
       
    34 
       
    35 /**
       
    36  * This class provides the implementation of the HTTP client
       
    37  */
       
    38 
       
    39 NONSHARABLE_CLASS ( CIRHttpDataProvider ): public CBase,
       
    40 										public MHTTPTransactionCallback
       
    41 									
       
    42     {
       
    43     public:
       
    44     /**
       
    45      * CIRHttpDataProvider::CIRHttpDataProvider(MIRHttpDataProviderObserver&
       
    46 	 * aObserver):iObserver(aObserver),iRunning(EFalse)
       
    47      * Creates instance of CIRHttpDataProvider.
       
    48      * @param aObserver Reference to HTTP Data provider observer
       
    49      */
       
    50     CIRHttpDataProvider( MIRHttpDataProviderObserver &aObserver );
       
    51     /**
       
    52      * CIRHttpDataProvider::~CIRHttpDataProvider()
       
    53      * Destructs instance of CIRHttpDataProvider.
       
    54      */
       
    55     virtual ~CIRHttpDataProvider();
       
    56     /**
       
    57      * CIRHttpDataProvider::NewL(MIRHttpDataProviderObserver& aObserver )
       
    58      * Creates instance of CIRHttpDataProvider.
       
    59      * @param aObserver Reference to HTTP Data provider observer
       
    60      */
       
    61     static CIRHttpDataProvider *NewL( MIRHttpDataProviderObserver &aObserver );
       
    62     /**
       
    63      *  CIRHttpDataProvider::NewLC(MIRHttpDataProviderObserver& aObserver)
       
    64      *  Creates instance of CIRHttpDataProvider.
       
    65      *  @param aObserver Reference to HTTP Data provider observer
       
    66      */
       
    67     static CIRHttpDataProvider *NewLC(MIRHttpDataProviderObserver &aObserver);
       
    68     /**
       
    69      * CIRHttpDataProvider::ConstructL()
       
    70      * 2nd phase construction
       
    71      */
       
    72     void ConstructL();
       
    73     /**
       
    74      * CIRHttpDataProvider::CancelTransactionL()
       
    75      * Cancel the issued Http transaction
       
    76      */
       
    77     void CancelTransaction();
       
    78     /**
       
    79      * CIRHttpDataProvider::GetHttpSession()
       
    80      * returns the iHttpSession
       
    81      */
       
    82     RHTTPSession GetHttpSession();
       
    83 
       
    84     /**
       
    85      *  CIRHttpDataProvider::IssueHttpRequestL(
       
    86 	 *  CIRHttpRequestData& aRequestInfo )
       
    87      *  Used to issue the request.
       
    88      *  @param aRequestInfo Reference to request object
       
    89      */
       
    90     TInt IssueHttpRequestL( CIRHttpRequestData &aRequestObject );
       
    91     /**
       
    92      *  CIRHttpDataProvider::SetHttpContentType(TDesC& aContentType,
       
    93 	 *  TDesC& aCharSet)
       
    94      *  Set the Http content type
       
    95      *  @param aContentType Specifies the Content-Type
       
    96      *  @param aCharSet Specifies the Charecter set
       
    97      */
       
    98     void SetHttpContentType(const TDesC &aContentType,
       
    99     	const TDesC &aCharSet);
       
   100 
       
   101     /**
       
   102      *  CIRHttpDataProvider::InitializeHttpDataProviderL();
       
   103      *  Initialize the data provider component
       
   104      */
       
   105     void InitializeHttpDataProviderL();
       
   106 
       
   107     /**
       
   108      *  CIRHttpDataProvider::ReleaseResources();
       
   109      *  Releases the resources held by data provider
       
   110      */
       
   111     void ReleaseResources();
       
   112 
       
   113     IMPORT_C CIRLogoDownloadEngine* GetLogoDownloadEngine();
       
   114 
       
   115     private:
       
   116     /**
       
   117      * CIRHttpDataProvider::MHFRunL()
       
   118      * Inherited from MHTTPTransactionCallback
       
   119      * Called by framework to pass transaction events.
       
   120      * @param aTransaction HTTP Transaction object
       
   121      * @param aEvent HTTP Transaction Event
       
   122      */
       
   123     void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent &aEvent );
       
   124     /**
       
   125      * CIRHttpDataProvider::MHFRunError()
       
   126      * Inherited from MHTTPTransactionCallback
       
   127      * Called by framework to pass transaction errors
       
   128      * @param aError Error code of the HTTP Transactin
       
   129      * @return TInt Return code KErrNone if success
       
   130      */
       
   131     TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction,
       
   132 		const THTTPEvent &aEvent );
       
   133     /**
       
   134      *  CIRHttpDataProvider::ExtractResponseHeadersL(
       
   135 	 *  RHTTPTransaction aTransaction )
       
   136      *  Used to Extract the response headers.
       
   137      *  @param aTransaction HTTP Transaction object
       
   138      */
       
   139     void ExtractResponseHeadersL( const RHTTPTransaction& aTransaction );
       
   140     /**
       
   141      *  CIRHttpDataProvider::SetHeaderL( RHTTPHeaders aHeaders, TInt
       
   142 	 *  aHeaderField, const TDesC8& aHeaderValue )
       
   143      *  Used to set the Http header
       
   144      *  @param aHeaders HTTP Headers object
       
   145      *    @param aHeaderField Header field
       
   146      *  @param aHeaderValue Header value
       
   147      */
       
   148     void SetHeaderL( RHTTPHeaders aHeaders, TInt aHeaderField,
       
   149 		const TDesC8 &aHeaderValue ) const;
       
   150 
       
   151     /**
       
   152      * CIRHttpDataProvider::BuildHeadersL(CIRHttpRequestData &aRequestInfo)
       
   153      * Build the headers for the request
       
   154      * @param CIRHttpRequestData&
       
   155     */
       
   156      void BuildHeadersL(const CIRHttpRequestData &aRequestInfo);
       
   157 
       
   158     /**
       
   159      * CIRHttpDataProvider::ValidateStatusCode(TInt aStatusCode)
       
   160      * Validate the status code returned
       
   161      * @param aStatusCode Status code
       
   162      */
       
   163     void ValidateStatusCode( TInt aStatusCode );
       
   164 
       
   165     /**
       
   166      *  CIRHttpDataProvider::CloseLogFile ();
       
   167      *  Used to Close the log file LogUsage.gz externally from other sources (bug-fixing)
       
   168      */
       
   169     void CloseLogFile ();
       
   170 
       
   171 
       
   172 public:
       
   173 
       
   174     /**
       
   175      * iSetNonUAProfUserAgent Set when the UAProf should not be used
       
   176      * may be used for image data provider
       
   177      */
       
   178     TBool iSetNonUAProfUserAgent;
       
   179 
       
   180 private:
       
   181 
       
   182 	/**
       
   183 	 * Status code of the response
       
   184 	 */
       
   185     TInt iStatusCode;
       
   186 
       
   187     /**
       
   188      * Indicates if the transaction is active ie. there is a pending
       
   189      * request.
       
   190      */
       
   191     TBool iRunning;
       
   192 
       
   193     /**
       
   194      * Used to identify first request to the data provider object
       
   195      */
       
   196     TBool iFirstTime;
       
   197 
       
   198     /**
       
   199      * HTTP session object
       
   200      */
       
   201     RHTTPSession iHttpSession;
       
   202 
       
   203     /**
       
   204      * HTTP transaction object
       
   205      */
       
   206     RHTTPTransaction iHttpTransaction;
       
   207 
       
   208     /**
       
   209      * HTTP Post object
       
   210      */
       
   211     CIRHttpPost* iLogMessage;
       
   212 
       
   213     CIRFavoritesDb* iFavDb;
       
   214 
       
   215     /**
       
   216      * Network controller handle pointer
       
   217      */
       
   218     CIRNetworkController *iIRNetworkControllerHandle;
       
   219 
       
   220     /**
       
   221      * Reference of the Http data provider Observer
       
   222      */
       
   223     MIRHttpDataProviderObserver &iObserver;
       
   224 
       
   225     /**
       
   226      * Status text of the response
       
   227      */
       
   228     TBuf < KMaxStatusTextLength > iStatusText;
       
   229 
       
   230     /**
       
   231      * Content type header info
       
   232      */
       
   233     TBuf8 < KDPMaxContentTypeLength > iContentType;
       
   234 
       
   235 	/**
       
   236      * Character set header info
       
   237      */
       
   238     TBuf8 < KMaxCharSetLength > iCharSet;
       
   239 
       
   240     /**
       
   241      * Set to ETrue if the response code is KNotModified ( 304 )
       
   242      */
       
   243     TBool iNotModified;
       
   244 
       
   245     /**
       
   246      * Pointet to Logo download
       
   247      */
       
   248     CIRLogoDownloadEngine* iLogoDownloadEngine;
       
   249 
       
   250     };
       
   251 #endif // IRHTTPDATAPROVIDER_H
       
   252 
       
   253