omadrm/drmengine/roap/inc/RoapHttpHandler.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 ROAP_HTTP_HANDLER_H
       
    20 #define ROAP_HTTP_HANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "RoapConnection.h"
       
    24 #include "RoapResponse.h"
       
    25 #include "RoapObserver.h"
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <http.h>
       
    29 #include <stringpool.h>
       
    30 #include <http/mhttpauthenticationcallback.h>
       
    31 
       
    32 namespace Roap
       
    33 {
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 class CRoapHttpHandler
       
    38 : public CActive,
       
    39   public MHTTPTransactionCallback,
       
    40   public MHTTPDataSupplier,
       
    41   public MHTTPAuthenticationCallback
       
    42     {
       
    43     public:     // Constructors and destructor
       
    44   
       
    45         static CRoapHttpHandler* NewL();
       
    46 
       
    47         virtual ~CRoapHttpHandler();
       
    48 
       
    49     public:     // new methods
       
    50 
       
    51         void CreateConnectionL( TRequestStatus* aStatus );
       
    52 
       
    53         void DoTransactionL
       
    54             (
       
    55             CRoapResponse& aResponse,
       
    56             TDesC8& aReqBody,
       
    57             TRequestStatus* aStatus 
       
    58             );
       
    59 
       
    60  
       
    61         void SetUrlL( TDesC8& aUrl );
       
    62 
       
    63         void SetObserver( MRoapObserver* aRoapObserver );
       
    64 
       
    65         void SetPreferredIap( TUint32 aPreferredIap );
       
    66 
       
    67     protected:  // from CActive
       
    68 
       
    69         virtual void DoCancel();
       
    70 
       
    71         virtual void RunL();
       
    72 
       
    73         virtual TInt RunError( TInt aError );
       
    74 
       
    75     protected:  // from MHTTPTransactionCallback
       
    76 
       
    77         virtual void MHFRunL
       
    78             ( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
       
    79 
       
    80         virtual TInt MHFRunError
       
    81             (
       
    82             TInt aError,
       
    83             RHTTPTransaction aTransaction,
       
    84             const THTTPEvent& aEvent
       
    85             );
       
    86 
       
    87     protected:  // from MHTTPDataSupplier
       
    88 
       
    89         virtual TBool GetNextDataPart( TPtrC8& aDataPart );
       
    90 
       
    91         virtual void ReleaseData();
       
    92 
       
    93         virtual TInt OverallDataSize();
       
    94 
       
    95         virtual TInt Reset();
       
    96 
       
    97 
       
    98     protected:  // from MHTTPAuthenticationCallback
       
    99     
       
   100 	    virtual TBool GetCredentialsL
       
   101             (
       
   102             const TUriC8& aURI,
       
   103             RString aRealm, 
       
   104             RStringF aAuthenticationType,
       
   105             RString& aUsername, 
       
   106             RString& aPassword
       
   107             );
       
   108 
       
   109     private:    // types
       
   110 
       
   111         enum TRoapState         ///< State.
       
   112             {
       
   113             EInit,
       
   114             EStart,
       
   115             EConnect,
       
   116             EReady,
       
   117             ERequest,
       
   118             EComplete,
       
   119             ECloseSession,
       
   120             };
       
   121 
       
   122     private:    // Constructors and destructor
       
   123      
       
   124         CRoapHttpHandler();
       
   125     
       
   126         void ConstructL();
       
   127 
       
   128     protected:    // state machine parts
       
   129 
       
   130 
       
   131         void ConnectL();
       
   132 
       
   133 
       
   134         void CreateSessionL();
       
   135 
       
   136 
       
   137         void DoTransactionL();
       
   138         
       
   139         
       
   140         void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
       
   141 
       
   142 
       
   143         void Complete();
       
   144 
       
   145 
       
   146         void InstallHttpFiltersL();
       
   147 
       
   148 
       
   149         void SelfComplete( TInt& aResult );
       
   150 
       
   151 
       
   152         void HandleResponseHeadersL( RHTTPResponse aHttpResponse );
       
   153         
       
   154         
       
   155         TBool CheckHttpCode( TInt aHttpStatus );
       
   156 
       
   157 
       
   158         TInt AppendPduData( const TDesC8& aDataChunk );
       
   159         
       
   160         
       
   161         TInt AppendMultipartData( const TDesC8& aDataChunk );
       
   162         
       
   163        
       
   164         static TInt StaticTimeOut( TAny* aPointer );
       
   165         
       
   166         
       
   167         void TimeOut();
       
   168 
       
   169     private:    // data
       
   170 
       
   171         HBufC8* iUri;
       
   172         HBufC8* iRequestBody;
       
   173         RHTTPSession iSession;
       
   174         RHTTPTransaction iTransaction;
       
   175         CRoapConnection* iConnection;
       
   176         MRoapObserver* iObserver;
       
   177         CRoapResponse* iResponse;
       
   178         HBufC8* iBoundary;
       
   179         TRequestStatus* iParentStatus;
       
   180         TUint32 iPreferredIap;
       
   181         TRoapState iState;
       
   182         TInt iError;
       
   183         CPeriodic* iTimeout;
       
   184         TInt iBytesReceived;
       
   185         TBool iReportBytes;
       
   186     };
       
   187 }
       
   188 
       
   189 #endif  // ROAP_HTTP_HANDLER